我已经构建了 Boost 1.68(使用https://gist.github.com/sim642/29caef3cc8afaa273ce6的说明,并添加link=static,shared
到 b2 命令行以构建共享库。)
这些库似乎可以正确构建,并且我已经正确设置了BOOST_INCLUDEDIR
和BOOST_LIBRARYDIR
环境变量。
但是,当我将以下内容添加到 a 时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
根据调试输出,查找脚本正在正确的目录 ( 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 变量来解决吗?