我想在我的C++項目中包含Boost的線程庫。我的CMake的文件是像這樣:鏈接Boost線程庫
cmake_minimum_required(VERSION 3.6)
project(LearningC)
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp Student.cpp Student.h)
add_executable(LearningC ${SOURCE_FILES})
target_link_libraries(LearningC ${Boost_LIBRARIES})
我得到一個錯誤:
Undefined symbols for architecture x86_64:
"boost::this_thread::interruption_point()", referenced from:
boost::condition_variable::wait(boost::unique_lock<boost::mutex>&) in main.cpp.o
[More stack traces...]
我在做什麼錯?
所以你需要在'find_package(Boost)'調用中列出'線程'庫:'find_package(Boost COMPONENTS thread REQUIRED)'。像[there](http://stackoverflow.com/a/3917033/3440745)。 – Tsyvarev
在我的情況下,我必須添加'find_package(Boost COMPONENTS thread system REQUIRED)'和'target_link_libraries( $ {Boost_LIBRARIES})''當然! –
Tanasis