我正在尝试运行应使用Boost库的程序,并且收到以下消息:
Undefined symbols for architecture x86_64:
"boost::detail::thread_data_base::~thread_data_base()", referenced from:
boost::detail::thread_data<KeyBoardAndSendTask>::~thread_data() in echoClient.cpp.o
boost::detail::thread_data<GetterTask>::~thread_data() in echoClient.cpp.o
"boost::thread::join_noexcept()", referenced from:
boost::thread::join() in echoClient.cpp.o
"boost::thread::native_handle()", referenced from:
boost::thread::get_id() const in echoClient.cpp.o
"boost::thread::start_thread_noexcept()", referenced from:
boost::thread::start_thread() in echoClient.cpp.o
"boost::thread::detach()", referenced from:
boost::thread::~thread() in echoClient.cpp.o
"boost::thread::interrupt()", referenced from:
_main in echoClient.cpp.o
"typeinfo for boost::detail::thread_data_base", referenced from:
typeinfo for boost::detail::thread_data<KeyBoardAndSendTask> in echoClient.cpp.o
typeinfo for boost::detail::thread_data<GetterTask> in echoClient.cpp.o
"vtable for boost::detail::thread_data_base", referenced from:
boost::detail::thread_data_base::thread_data_base() in echoClient.cpp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [Boost_Echo_Client] Error 1
make[2]: *** [CMakeFiles/Boost_Echo_Client.dir/all] Error 2
make[1]: *** [CMakeFiles/Boost_Echo_Client.dir/rule] Error 2
make: *** [Boost_Echo_Client] Error 2
有人知道我该如何解决吗? 如果有帮助,我正在编程服务器和客户端程序。
这是我的cmakeList:
cmake_minimum_required(VERSION 3.12)
project(Boost_Echo_Client)
set(CMAKE_CXX_STANDARD 14)
include_directories(include)
add_executable(Boost_Echo_Client
include/connectionHandler.h
src/connectionHandler.cpp
src/echoClient.cpp
makefile)
find_package(Boost COMPONENTS system filesystem REQUIRED)
IF (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(Boost_Echo_Client
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
)
endif()
恶作剧!