我正在尝试在Ubuntu14.4上编译mongo-cxx-driver-r3.1.1。我已经按照说明从源代码安装了mongo-c-driver-1.6.3。

pkg-config --cflags --libs libmongoc-1.0 libbson-1.0 returns
-I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0  -L/usr/local/lib -lmongoc-1.0 -lsasl2 -lssl -lcrypto -lrt -lbson-1.0


我有增强版1.57。当我尝试使用cmake按照https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/中提供的说明编译mongo-cxx-driver-r3.1.1时。

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local  ..


我得到以下日志:


  -Boost版本:1.57.0
  
  -配置完成
  
  -完成生成
  
  -构建文件已写入:/user/home/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build


我尝试了其他选择,例如:

cmake  -DBSONCXX_POLY_USE_MNMLSTC:Bool=OFF -DBSONCXX_POLY_USE_BOOST:Bool=ON -

DCMAKE_VERBOSE_MAKEFILE=ON  -DCMAKE_C_COMPILER="/usr/bin/gcc" -
DCMAKE_CXX_COMPILER="/usr/bin/g++-4.8"  -DCMAKE_BUILD_TYPE=Release -
DCMAKE_INSTALL_PREFIX=/usr/local -DLIBMONGOC_DIR=/usr/local/lib -
DLIBBSON_DIR=/usr/local/lib ..


但是,我看不到与mongocxx相关的库或头文件。以下是CMakeFiles / CMakeOutput.log输出:


  系统为:Linux-3.13.0-32-generic-x86_64编译CXX
  
  编译器标识源文件“ CMakeCXXCompilerId.cpp”
  
  成功了。编译器:/usr/bin/g++-4.8构建标志:ID标志:


输出为:


  0


CXX编译器标识源“ CMakeCXXCompilerId.cpp”的编译产生“ a.out”

CXX编译器标识为GNU,可在“ /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/3.2.2/CompilerIdCXX/a.out”中找到

确定CXX编译器是否工作,并通过以下输出传递:
更改目录:/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp

运行构建命令:“ / usr / bin / make”“ cmTryCompileExec1480695504 / fast”

ake [1]:进入目录/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp'/usr/bin/cmake -E cmake_progress_report /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/CMakeFiles 1Building CXX object CMakeFiles/cmTryCompileExec1480695504.dir/testCXXCompiler.cxx.o/usr/bin/g++-4.8 -o CMakeFiles/cmTryCompileExec1480695504.dir/testCXXCompiler.cxx.o -c /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxxLinking CXX executable cmTryCompileExec1480695504/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1480695504.dir/link.txt --verbose=1/usr/bin/g++-4.8 CMakeFiles/cmTryCompileExec1480695504.dir/testCXXCompiler.cxx.o -o cmTryCompileExec1480695504 -rdynamicmake[1]: Leaving directory /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp'

检测使用以下输出编译的CXX编译器ABI信息:
更改目录:/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp

运行构建命令:“ / usr / bin / make”“ cmTryCompileExec4079379117 / fast”
.............

...................



/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/src.cxx:2:25:警告:\ u2018int somefunc()\ u2019已过时(在/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/src.cxx:1处声明)[-Wdeprecated-declarations]
     int main(){return somefunc();}
                         ^
/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/src.cxx:2:34:警告:\ u2018int somefunc()\ u2019已过时(在/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/src.cxx:1处声明)[-Wdeprecated-declarations]
     int main(){return somefunc();}
                                  ^
链接CXX可执行文件cmTryCompileExec1892014975
/ usr / bin / cmake -E cmake_link_script CMakeFiles / cmTryCompileExec1892014975.dir / link.txt --verbose = 1
/usr/bin/g++-4.8 -DCOMPILER_HAS_DEPRECATED_ATTR CMakeFiles / cmTryCompileExec1892014975.dir / src.cxx.o -o cmTryCompileExec1892014975 -rdynamic
make [1]:离开目录`/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp'

源文件为:
attribute((deprecated))int somefunc(){return 0; }
    int main(){return somefunc();}

如果有意义,我可以发布整个cmake输出。我在文件中表示“错误”或“失败”,但是找不到任何字符串。

如果有人可以指出,那真是太好了,我在这里缺少什么?

最佳答案

这个bash文件适用于Ubuntu 16.04

#!/bin/bash
apt-get update >> /dev/null
apt-get install openssh-server -y
apt-get install g++ -y
apt-get install cmake -y
apt-get install git -y
#installing the mongoc dependencies and driver
apt-get install pkg-config libssl-dev libsasl2-dev -y
cd ~
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.6.2/mongo-c-driver-1.6.2.tar.gz
tar xzf mongo-c-driver-1.6.2.tar.gz
cd mongo-c-driver-1.6.2
./configure --disable-automatic-init-and-cleanup
make
make install
cd ~
rm mongo-c-driver-1.6.2.tar.gz
rm -rf mongo-c-driver-1.6.2


#installing mongocxx driver - connects c++ to mongo
wget https://github.com/mongodb/mongo-cxx-driver/archive/r3.1.1.tar.gz
tar -xzf r3.1.1.tar.gz
cd mongo-cxx-driver-r3.1.1/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
make EP_mnmlstc_core
make
make install
cd ~
rm r3.1.1.tar.gz
rm -rf mongo-cxx-driver-r3.1.1

10-06 12:55