CMake Boost静态库未定义参考boost :: chrono :: steady_clock :: now()

时间:2017-08-02 22:32:59

标签: boost cmake

我正在尝试使用MinGW和CMake在Windows上构建一个使用Boost库v1.60.0的项目。我能够使用MinGW成功构建Boost,具体如下:

cd <boost_root>\tools\build
bootstrap.bat gcc
cd ..\..
tools\build\b2.exe --prefix=<boost_install_root> toolset=gcc link=static

现在当我通过CMake构建我的应用程序时,我这样做:

add_executable(myApp ... .cpp sources ...)
target_include_directories(myApp <myApp include directory> ${Boost_INCLUDE_DIRS})
target_link_libraries(myApp ${Boost_LIBRARIES})

我得到的几个错误几乎完全相同:

<boost_install_root>/lib/libboost_timer-mgw53-mt-1_60.a(cpu_timer.o):cpu_ timer.cpp:(.text+0x25a): undefined reference to `boost::chrono::steady_clock::now()'

这些图书馆都在那里,从我能说的内容中可以看到CMake,所以我错过了什么?

1 个答案:

答案 0 :(得分:0)

将我以前的评论重新格式化为答案:

为了使链接正常工作,库的顺序很重要。由于Boost计时器库依赖于计时库的功能,因此您需要在find_package调用中重新排序库。

我不知道有一个网页可以提供Boost库的所有相互依赖关系,但bcp可能是一个起点。

相关问题