2013-04-23 82 views
0

我從http://dl.mongodb.org/dl/cxx-driver下載了最新的代碼並將其編譯爲Ubuntu 12.04上的靜態庫& 12.10。 我的GCC是4.7,並且使用CMake作爲構建系統。 Boost庫:在Ubuntu 12.04上爲1.48,在Ubuntu 12.10上爲1.49。MongoDB 2.4 C++驅動程序導致鏈接錯誤

然後,我的兩個項目的MongoDB客戶端庫編譯成功,但第三個項目獲得如下鏈接錯誤:

Linking CXX executable cml_cloud 

/usr/lib/gcc/x86_64-linux-gnu/4.7/../ ../../../lib/libmongoclient.a(log.o):函數mongo::LoggingManager::start(std::string const&, bool)': log.cpp:(.text._ZN5mongo14LoggingManager5startERKSsb[_ZN5mongo14LoggingManager5startERKSsb]+0x4c): undefined reference to boost :: filesystem3 :: detail :: status(boost :: filesystem3 :: path const &,boost :: system :: error.code *)' log.cpp :(。text._ZN5mongo14LoggingManager5startERKSsb [_ZN5mongo14LoggingManager5startERKSsb] + 0x86):undefined reference to boost::filesystem3::detail::status(boost::filesystem3::path const&, boost::system::error_code*)' log.cpp:(.text._ZN5mongo14LoggingManager5startERKSsb[_ZN5mongo14LoggingManager5startERKSsb]+0xb8): undefined reference to boost :: filesystem3 :: detail :: status(boost :: filesystem3 :: path const &,boost :: system ::埃羅r_code *)' collect2:error:ld returned 1 exit status make [2]:* [bin/cml_cloud] Error 1 make [1]:* [bin/CMakeFiles/cml_cloud.dir/all] Error 2 品牌:* [全部]錯誤2

我從來沒有遇到過這種問題。 如何解決它?

回答

0

我修好了。這與mongodb庫無關,我只是改變了CMakeLists.txt中target_link_libraries的順序。

原來的說法是:

target_link_libraries(cml_cloud ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} cppcms mongoclient booster loki cryptopp) 

現在它看起來像:

target_link_libraries(cml_cloud ${CMAKE_THREAD_LIBS_INIT} cppcms mongoclient booster loki cryptopp ${Boost_LIBRARIES}) 

我現在很高興,但任何人都知道爲什麼它可以解決這個問題呢?

相關問題