【发布时间】:2014-01-24 23:55:36
【问题描述】:
我使用的是 Windows 系统。我想通过 CMake 使用 Boost 库。 我已经在 C:\boost_1_55_0\ 上安装了 boost 这是我的 CMakeLists.txt 文件
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()
我得到了——找不到 Boost 输出:
$ 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
【问题讨论】:
-
在再次运行
cmake之前尝试设置BOOST_ROOT=C:\boost_1_55_0。另请查看cmake --help-module FindBoost以获得更多帮助。 -
这有帮助。谢谢。请作为答案。准确地说应该是“set(BOOST_ROOT C:/boost_1_55_0)
-
您不必将
set(...放入您的 CMakeLists.txt 中!在调用cmake之前设置一个环境变量。
标签: visual-studio-2010 boost cmake