为什么MongoDB C ++驱动程序无法在SLES11上运行?

时间:2015-08-14 14:49:16

标签: c++ linux mongodb boost sles

我一直在研究在Zlinux上安装MongoDB驱动程序,到目前为止,除了SLES11之外,我还能在大多数Linux系统上工作。

现在为了获得代码,我不得不对GCC和Boost进行一些更新。这意味着系统正在运行以下内容:

test@ff6d8405cc0c:~/work> g++ --version
g++ (GCC) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

test@ff6d8405cc0c:~/work> cat /usr/local/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
//  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_58"
test@ff6d8405cc0c:~/work> cat /usr/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
//  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_36"

因为我有2个版本的提升,我按如下方式设置了我的路径:

test@ff6d8405cc0c:~/work> echo $PATH
/home/test/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:.:/usr/local/include/:/usr/local/lib/

但我测试与数据库连接的g ++脚本仍然失败,这是脚本:

#include <cstdlib>
#include <iostream>
#include "mongo/client/dbclient.h" // for the driver

void run() {
 mongo::DBClientConnection c;
  c.connect("localhost");
}

int main() {
    mongo::client::initialize();
    try {
        run();
        std::cout << "connected ok" << std::endl;
   } catch( const mongo::DBException &e ) {
        std::cout << "caught " << e.what() << std::endl;
    }
    return EXIT_SUCCESS;
}

我安装的MongoDB C ++驱动程序使用以下scons标志按预期工作:

sudo scons --prefix=/usr/local --disable-warnings-as-errors install

但我的一部分人怀疑它错误地称它为错误的库提升。当我尝试编译C ++时,我只是遇到了一大堆错误:

  

测试@ ff6d8405cc0c:〜/工作&GT; g ++ example-connect.cpp -pthread -lmongoclient -lboost_thread -lboost_system -lboost_program_options -lboost_system -lboost_regex -o example-connect
      /usr/local/lib/gcc/s390x-ibm-linux-gnu/5.2.0/../../../libmongoclient.a(dbclient.o):在函数boost::thread_exception::thread_exception(int, char const*)': /usr/local/include/boost/thread/exceptions.hpp:51: undefined reference to boost :: system中:: system_category()&#39;       /usr/local/lib/gcc/s390x-ibm-linux-gnu/5.2.0/../../../libmongoclient.a(dbclient.o):在函数__static_initialization_and_destruction_0': /usr/local/include/boost/system/error_code.hpp:221: undefined reference to boost :: system中:: generic_category()&#39;       /usr/local/include/boost/system/error_code.hpp:222:对boost::system::generic_category()' /usr/local/include/boost/system/error_code.hpp:223: undefined reference to boost :: system :: system_category()&#39;的未定义引用       /usr/local/lib/gcc/s390x-ibm-linux-gnu/5.2.0/../../../libmongoclient.a(dbclient.o):在函数`boost :: re_detail :: perl_matcher&lt; __gnu_cxx :: __ normal_iterator,std :: allocator&gt; &gt;,std :: allocator,std :: allocator&gt; &GT; &GT; &gt;,boost :: regex_traits&gt; &GT; :: match_prefix()&#39;:

我自己做了一些研究,但我不能100%确定接下来要做什么,以确保我能调用所有正确的组件。

0 个答案:

没有答案