首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >C++ Boost:对boost::system::generic_category()的引用未定义

C++ Boost:对boost::system::generic_category()的引用未定义
EN

Stack Overflow用户
提问于 2012-11-20 13:24:52
回答 8查看 130.3K关注 0票数 98

我正在尝试将Boost库包含在我的项目中,并且一直面临着同样的问题。我在Ubuntu 12.10上使用Codeblocks,并尝试手动安装库,从网站读取说明,但在标题和待构建的使用前库中遇到错误。

然后我通过terminalby sudo apt-get install libboost-all-dev安装库。在此之后,在我的代码块程序中,我可以包含像#include <boost/regex.hpp>这样的头文件,但是当我尝试包含文件系统库( #include "boost/filesystem/operations.hpp" )的头文件时,我得到了以下错误:

代码语言:javascript
运行
复制
/usr/include/boost/system/error_code.hpp|214|undefined reference to boost::system::generic_category()'|

我不确定如何解决这个错误(特别是在Linux上的Codeblock中)。我真的需要一些帮助。

编译: Gcc

程序代码:仅尝试包含上述文件系统operations.hpp文件。

从代码块构建日志:

代码语言:javascript
运行
复制
Build started on: 20-11-2012 at 18:02.53
Build ended on: 20-11-2012 at 18:02.54
-------------- Build: Debug in libopenFrameworks ---------------
Target is up to date.
-------------- Build: Debug in reader1 ---------------
make -s -f Makefile Debug
linking i686 bin/reader1_debug linux
obj/i686Debug/src/testApp.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
obj/i686Debug/src/main.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
collect2: ld returned 1 exit status
make: *** [bin/reader1_debug] Error 1
Process terminated with status 2 (0 minutes, 1 seconds)
6 errors, 0 warnings
EN

Stack Overflow用户

发布于 2019-04-20 01:23:02

在测试了上面描述的建议的解决方案后,我发现只有这几行可以工作。

我使用的是Ubuntu 16.04。

Cmake_minimum_required(版本3.13)

项目(MyProject)

set(CMAKE_CXX_STANDARD 11)

add_executable(myProject main.cpp)

find_package(Boost 1.58.0必需组件系统文件系统)

target_link_libraries(myProject ${Boost_LIBRARIES})

票数 0
EN
查看全部 8 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13467072

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档