对于cmake构建的工程项目:
# CmakeList.txt添加如下内容
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
# 或者
find_package(Boost 1.55.0 REQUIRED COMPONENTS system filesystem)
include_directories(untitled ${Boost_INCLUDE_DIRS})
link_directories(untitled ${Boost_LIBRARY_DIRS})
target_link_libraries(untitled ${Boost_LIBRARIES})
对于 g++ 编译器,需要添加编译选项,进行库的链接:
出现的问题:
/usr/include/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
解决:
g++ -o test main.cpp -lboost_system
问题:
对‘vtable for boost::detail::threa