在CMakeLists.txt中使用find_包(Boost…)时发生CMake错误:未找到合适的构建变体
使用CMake时,调用在CMakeLists.txt中使用find_包(Boost…)时发生CMake错误:未找到合适的构建变体,boost,cmake,Boost,Cmake,使用CMake时,调用find\u package(需要Boost 1.6组件程序\u选项线程系统)时出现以下错误: 我不明白这里的问题。我为include和lib目录添加了环境变量。我使用的是CMake 3.17.0和Boost 1.72.0,错误的重要部分如下: No suitable build variant has been found. The following variants have been tried and rejected: * libboost_pr
find\u package(需要Boost 1.6组件程序\u选项线程系统)
时出现以下错误:
我不明白这里的问题。我为
include
和lib
目录添加了环境变量。我使用的是CMake 3.17.0和Boost 1.72.0,错误的重要部分如下:
No suitable build variant has been found.
The following variants have been tried and rejected:
* libboost_program_options-vc142-mt-gd-x32-1_72.lib (32 bit, need 64)
* libboost_program_options-vc142-mt-gd-x64-1_72.lib (static,
Boost_USE_STATIC_LIBS=OFF)
* libboost_program_options-vc142-mt-x32-1_72.lib (32 bit, need 64)
* libboost_program_options-vc142-mt-x64-1_72.lib (static,
Boost_USE_STATIC_LIBS=OFF)
它显示了找到的库,并给出了它们被拒绝的原因。这里的所有库都是静态的,如名称上的lib
前缀所示。但是,您的CMake配置表明您不想使用静态库(Boost\u use\u static\u LIBS=OFF
)。要修复错误,您有两个选项:
Boost\u USE\u STATIC\u LIBS
设置为打开:
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.6 COMPONENTS program_options thread system REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.6 COMPONENTS program_options thread system REQUIRED)