您的位置:首页 > 编程语言 > C语言/C++

C++中Boost使用出现错误undefined reference to `boost::system::generic_category()'解决方法

2018-03-01 15:06 1736 查看
编译环境 ubuntu16.04

idea Clion

运行出现问题

CMakeFiles/untitled.dir/main.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
/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()'


解决方法

命令行编译

添加-lboost_system属性进行编译

rui@Hopo:~/CLionProjects/untitled$ g++ main.cpp -lboost_system


Clion编译器配置CmakeList.txt添加如下内容解决

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})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Boost
相关文章推荐