折腾boost库,msvc,clion
1.一开始想在clion下配置boost库,把所有的变量都设置过了,没有作用,也参考了googleHow to include external library (boost) into CLion C++ project with CMake? - Stack Overflow
2.一直报错CONNOT FIND BOOST 然后意识到直接设置文件夹根本就是不对的,文件夹下并没有动态库,只有一个一个文件夹
这根本是不对的,应该填的是一个有库文件的文件夹
3.然后下载了boost(最开始下载的都是最新的boost,boost需要用msvc解压,最新的版本不太兼容,然后使用的是boost1.77 和vs2019) 通用的流程网上全部都是 ,随便贴一个在IDE中集成boost - 傲衣华少 - 博客园 (cnblogs.com)
4.boost编译报错 connot find ctype.h 等一系列找不到文件的报错,最后发现是vs没有安装sdk导致的 https://github.com/microsoft/vcpkg/issues/19544
5.clion还是报错,参考https://stackoverflow.com/questions/71610458/could-not-find-boost-missing-system-found-suitable-versihow-on-1-78-0-min,大致是编译过的boost库不需要COMPONENTS
最后贴一下配置
cmake_minimum_required(VERSION 3.23) project(test) set(CMAKE_CXX_STANDARD 14) set(Boost_DETAILED_FAILURE_MSG ON) set(Boost_INCLUDE_DIR D:/clion/boost177/boost_1_77_0) set(Boost_LIBRARY_DIR D:/clion/boost177/boost_1_77_0/stage/lib) include_directories(${Boost_INCLUDE_DIR}) message(STATUS "start running cmake...") find_package(Boost 1.77.0 ) if(Boost_FOUND) message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}") message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}") message(STATUS "Boost_VERSION: ${Boost_VERSION}") include_directories(${Boost_INCLUDE_DIRS}) endif() add_executable(test main.cpp) if(Boost_FOUND) target_link_libraries(test ${Boost_LIBRARIES}) endif()