更新时间:2023-02-26 20:30:23
您需要将环境变量 BOOST_ROOT
设置为 C:\\ boost_1_55_0
运行前 cmake的
。另外,也要看看 cmake的--help模块FindBoost
以获得更多帮助。
I'm using a windows system. I want to use the Boost library using CMake. I've installed boost on C:\boost_1_55_0\ Here is my CMakeLists.txt file
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.55.0 COMPONENTS thread)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
add_executable (linking_with_boost main.cc sqr.cc)
target_link_libraries(linking_with_boost ${Boost_LIBRARIES})
else()
message(STATUS "Fail asdasd!")
endif()
I'm getting --Could NOT find Boost Output:
$ cmake ../
-- Could NOT find Boost
-- Fail asdasd!
-- Configuring done
-- Generating done
-- Build files have been written to: D:/ubuntu_share/programming/C++/practice/cm
ake/linking_with_boost/build_win
You need to set the environment variable BOOST_ROOT
to c:\boost_1_55_0
before running cmake
. Also look at cmake --help-module FindBoost
for more help.