c++ - mongo-cxx-driver 安装会安装库

标签 c++ mongodb mongo-cxx-driver

我正在尝试在 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

我有 boost 版本 1.57。当我尝试按照 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 version: 1.57.0

-- Configuring done

-- Generating done

-- Build files have been written to: /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 输出:

The system is: Linux - 3.13.0-32-generic - x86_64 Compiling the CXX

compiler identification source file "CMakeCXXCompilerId.cpp"

succeeded. Compiler: /usr/bin/g++-4.8 Build flags: Id flags:

输出是:

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.出”

通过以下输出确定 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 1 构建 CXX 对象 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.cxx 链接 CXX 可执行文件 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 -rdynamic make[1]: 离开目录/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() { 返回 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() { 返回 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'

源文件是: 属性((已弃用)) 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

关于c++ - mongo-cxx-driver 安装会安装库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44723265/

相关文章:

c++ - 将函数作为模板类型传递并在 C++ 中扣除其类型

c++ - C++98 的事件对象

mongodb - 获取 MongoDB 索引中的文档数

c++ - 如何使用 C++ 在 MongoDB 中创建地理空间索引

c++ - 如何在 Visual Studio 中使用 mongodb-cxx-driver 设置项目

c++ - 如何在 mongocxx find_one_and_update 的文档中设置值

c++ - 如果我们不知道列表的开头,如何在未指定参数的函数中初始化 ap?

c++ - 如何在 C++ 中异步执行一个函数?

mongodb - 为什么 Spring Data MongoDB 无法实例化这种嵌套类型结构?

mongodb - MongoDb 中的 "queries"和 "commands"有什么区别