• linux安装mongo c++ driver,出现Checking for C++ library boost_threadmt... no的解决办法


    • build mongo-cxx-driver-v2.2

    从mongodb官方网站下载mongo c++ driver程序包:mongodb-linux-x86_64-2.2.0.tar。解压后运行scons。

    $ cd mongo-cxx-driver-v2.2

    $ scons

    scons: Reading SConscript files ...

    Checking for C++ library boost_thread-mt... no

    Checking for C++ library boost_thread... no

    出现问题。可见它依赖于boost库。

    • 用apt-get安装boost开发和文档库

    $ sudo apt-get install libboost-dev libboost-doc

    安装成功后,回到mongo-cxx-driver-v2.2目录再次运行scons,现象依旧。

    • 用apt-get安装全部boost库

    $ sudo apt-get install libboost*

    The following packages have unmet dependencies:

     libboost-date-time1.42-dev : Conflicts: libboost-date-time1.40-dev but 1.40.0-6ubuntu1 is to be installed

     libboost-filesystem1.42-dev : Conflicts: libboost-filesystem1.40-dev but 1.40.0-6ubuntu1 is to be installed

    libboost1.42-dbg : Conflicts: libboost1.40-dbg but 1.40.0-6ubuntu1 is to be installed

     libboost1.42-dev : Conflicts: bcp

                        Conflicts: libboost1.40-dev but 1.40.0-6ubuntu1 is to be installed

     libboost1.42-doc : Conflicts: libboost1.40-doc but 1.40.0-6ubuntu1 is to be installed

    E: Broken packages

    Boost内部依赖出问题,干脆下载源文件自己build。

    • 下载boost 1.51版本并build

    $ cd boost_1_51_0

    $ ./bootstrap.sh

    $ ./b2

    $ sudo ./b2 install

    这个过程很长,需要耐心等待。

    • 再次build mongo-cxx-driver-v2.2

    build成功后,回到mongo-cxx-driver-v2.2目录再次运行scons,现象依旧。

    $ cd mongo-cxx-driver-v2.2

    $ scons

    In file included from /usr/local/include/boost/filesystem/path.hpp:24,

                     from src/mongo/util/paths.h:26,

                     from src/mongo/db/client.h:38,

                     from src/mongo/db/curop.h:23,

                     from src/mongo/db/curop-inl.h:1,

                     from src/mongo/db/instance.h:23,

                     from src/mongo/db/dbmessage.h:25,

                     from src/mongo/client/dbclient_rs.cpp:27:

    /usr/local/include/boost/filesystem/config.hpp:16: error: #error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3

    scons: *** [build/mongo/client/dbclient_rs.o] Error 1

    scons: building terminated because of errors.

    看来是文件系统版本不兼容。查阅了资料,mongo c++ driver只支持boost filesystem V2。

    Boost官网http://www.boost.org/doc/libs/1_51_0/libs/filesystem/doc/index.htm有这么一段话:

    This is Version 3 of the Filesystem library. Version 2 is not longer supported. 1.49.0 was the last release of Boost to supply Version 2。

    于是决定安装boost 1.49的版本

    • 下载boost 1.49版本并build

    成功

    • 再次build mongo-cxx-driver-v2.2

    $ cd mongo-cxx-driver-v2.2

    $ scons

    $ sudo scons install

    大功告成。现在你可以开始用c++编写操作mongoDB的程序了。

  • 相关阅读:
    Ubuntu VIM下实现python自动缩进
    认识Python和基础知识
    Linux常用服务器搭建
    VIM常用命令
    Linux基础
    LINUX操作系统VIM的安装和配置
    Ubuntu 16.04下安装搜狗输入法
    Ubuntu 16.04下sublime text3安装
    Ubuntu软件安装与卸载
    present(模态)实现出push的效果
  • 原文地址:https://www.cnblogs.com/mobileinternet/p/2665144.html
Copyright © 2020-2023  润新知