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つのバージョンを持っているので、次のようにパスを設定しました:

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/

しかし、DB への接続をテストするための私の 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