CMake找不到boost

找不到库Boost

1
2
3
4
5
6
set(Boost_DEBUG 1)
set(BOOST_ROOT "C:/Program Files/boostqww")


# SET (Boost_USE_STATIC_LIBS ON)
# SET (Boost_USE_STATIC_RUNTIME ON)

错误

1
Could NOT find Boost (missing: program_options system) (found suitable version "1.70.0", minimum required is "1.65.0")

Installing boost on Windows using MinGW-w64 (gcc 64-bit)
在CMakeLists.txt中set(Boost_DEBUG 1)
打印信息

1
2
Searching for SYSTEM_LIBRARY_RELEASE: boost_system-mgw13-mt-1_83;boost_system-mgw13-mt;boost_system-mgw13-mt;boost_system-mt-1_83;boost_system-mt;boost_system-mt;boost_system-mt;boost_system
Searching for PROGRAM_OPTIONS_LIBRARY_RELEASE: boost_program_options-mgw13-mt-1_83;boost_program_options-mgw13-mt;boost_program_options-mgw13-mt;boost_program_options-mt-1_83;boost_program_options-mt;boost_program_options-mt;boost_program_options-mt;boost_program_options

找不到文件名,所以修改C:\boost\lib中的文件名称libboost_system-mgw13-mt-d-x64-1_83.dll.a更改为libboost_system-mgw13-mt-1_83.dll.alibboost_program_options-mgw13-mt-d-x64-1_83.dll.a更改为libboost_program_options-mgw13-mt-1_83.dll.a
这里使用的是动态链接库

boost使用静态链接库(static libraries),报错需要libboost_program_options-mgw13-mt-1_83.dll.a

使用静态链接库:将libboost_program_options-mgw13-mt-sd-x64-1_83.a改名为libboost_program_options-mgw13-mt-1_83.a
可选的:在CMakeLists中set(Boost_USE_STATIC_LIBS ON)