【发布时间】:2018-08-17 17:25:06
【问题描述】:
我已经构建了 Boost 1.68(使用来自 https://gist.github.com/sim642/29caef3cc8afaa273ce6 的指令,并将 link=static,shared 添加到 b2 命令行以构建共享库。)
这些库似乎可以正确构建,并且我已正确设置了 BOOST_INCLUDEDIR 和 BOOST_LIBRARYDIR 环境变量。
但是,当我将以下内容添加到 CMakeLists.txt 时:
find_package(Boost REQUIRED COMPONENTS system context coroutine thread random REQUIRED)
并使用MinGW Makefiles 生成,我收到以下错误:
CMake Error at C:/Users/pbelanger/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/182.4129.15/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:2044 (message):
Unable to find the requested Boost libraries.
Boost version: 1.68.0
Boost include path: C:/boost/install/include/boost-1_68
Could not find the following static Boost libraries:
boost_system
boost_context
boost_coroutine
boost_thread
boost_random
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
我已将添加set(Boost_DEBUG ON) 的输出放在find_package 行之前:https://pastebin.com/yRd5DPt4
根据调试输出,find 脚本正在正确的目录 (c:\boost\install\lib) 中搜索,但没有找到 boost 库,因为它们具有不同的命名方案。例如,system 库名为 libboost_system-mgw81-mt-x64-1_68.dll,但查找脚本将库名称 boost_system-mgw81-mt-1_68 传递给 CMake 的 find_library。请注意,寻址模型 (-x64) 未列在后一个名称中。
我的问题是这是否是 Boost 或 findCMake 脚本的问题?这可以通过在 findCMake 脚本之前设置特定的 cmake 变量来解决吗?
【问题讨论】:
-
我的 boost 库目录列表在这里:pastebin.com/Sb0p4yzW
标签: c++ windows boost cmake cmake-modules