1

我一直致力于在 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 个版本的 boost,因此我将路径设置如下:

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++ 时,我得到了很多错误:

test@ff6d8405cc0c:~/work> 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 toboost::system::system_category()' /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 toboost::system::generic_category()' /usr/local/include/boost/system/error_code.hpp: 222:未定义的引用boost::system::generic_category()' /usr/local/include/boost/system/error_code.hpp:223: undefined reference toboost::system::system_category()' /usr/local/lib/gcc/s390x-ibm-linux-gnu/5.2.0/../../../libmongoclient.a(dbclient.o): 在函数`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator, std::allocator > >, std::allocator, std::allocator > > > >, boost::regex_traits > >::match_prefix()':

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

4

0 回答 0