【问题标题】:MongoDB 2.4 C++ driver causes link errorMongoDB 2.4 C++ 驱动程序导致链接错误
【发布时间】:2013-04-23 01:23:16
【问题描述】:

我从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客户端库编译成功,但是第三个项目出现以下链接错误:

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 toboost::filesystem3 ::detail::status(boost::filesystem3::path const&, boost::system::error_code*)' log.cpp:(.text._ZN5mongo14LoggingManager5startERKSsb[_ZN5mongo14LoggingManager5startERKSsb]+0x86): 未定义引用boost::filesystem3::detail::status(boost::filesystem3::path const&, boost::system::error_code*)' log.cpp:(.text._ZN5mongo14LoggingManager5startERKSsb[_ZN5mongo14LoggingManager5startERKSsb]+0xb8): undefined reference toboost::filesystem3::detail::status(boost::filesystem3::path const&, boost::system::error_code* )' collect2:错误:ld 返回 1 个退出状态 make[2]: * [bin/cml_cloud] 错误 1 make[1]: * [bin/CMakeFiles/cml_cloud.dir/all] 错误 2 make: * [all] 错误 2

我以前从未遇到过这种问题。 如何解决?

【问题讨论】:

标签: mongodb


【解决方案1】:

我修好了。这与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})

我现在很高兴,但有人知道为什么它可以纠正这个问题吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-31
    • 1970-01-01
    • 2013-07-06
    相关资源
    最近更新 更多