当前位置: 首页 > 知识库问答 >
问题:

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

虞华翰
2023-03-14

我正试图将Boost库包括在我的项目中,并一直面临着同样的问题。我在使用Codeblocks IDE的Ubuntu12.10上,尝试手动安装库,阅读网站上的说明,但在使用库之前,得到了带有标题的错误以及要构建的错误。

然后,我通过terminalbysudo apt get install libboost all dev安装了这些库。在此之后,在我的代码块程序中,我可以包含像#include这样的头文件

/usr/include/boost/system/error_code.hpp|214|undefined reference to boost::system::generic_category()'|

我不知道如何解决这个错误(特别是在Linux上的代码块中)。我真的需要一些帮助。

编译器:Gcc
程序代码:仅尝试包含上述文件系统操作。hpp文件。

从代码块构建日志

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

共有3个答案

柯子琪
2023-03-14

这是一个链接器问题。将静态库路径包括到项目中。

对于Qt Creator,打开项目文件。pro并添加以下行:

LIBS += -L<path for boost libraries in the system> -lboost_system

在我的情况下Ubuntux86_64:

LIBS += -L/usr/lib/x86_64-linux-gnu -lboost_system

对于代码块,打开设置-

boost_system

到链接库文本小部件,然后按OK按钮。

百里智勇
2023-03-14

根据boost版本的不同,libboost系统附带了-mt后缀,它应该表示库的多线程功能。

所以如果链接器找不到lboost_system,请尝试lboost_system。

慕飞章
2023-03-14

您应该链接到libboost_system库。我不确定代码块,但是您平台上的g命令行选项将是

-lboost_系统

 类似资料:
  • 问题内容: 我试图将库包含在我的项目中,并且一直面临着同样的问题。我在使用Codeblocks IDE的Ubuntu 12.10上,尝试手动读取站点上的说明来安装库,但是在头文件以及使用前需要构建的库中出现错误。 然后,我通过terminalby安装了库。此后,在我的代码块程序中,可以包含类似的标题,但是当我尝试包含Filesystem库的标题( )时,出现以下错误: 我不确定如何解决此错误(特别

  • 我正在尝试使用AassetManager从android apk访问资产。然而,尽管我已经包含了asset_manager.h和asset_manager_jni.h,但我仍然得到了“对aassetmanager_fromjava的未定义引用”。其他来自asset_manager.h的函数,如AAssetManager_openDir(mgr,"“)等也不能被引用。 以下是完整的代码 这段代码在一

  • 错误:未定义对'pthread_cancel'的引用

  • 问题内容: 我正在使用Linux,并且具有以下文件: 该函数在中声明和定义。我需要在中使用该函数,因此我将该函数声明为 在。 但是,在编译过程中,我得到了错误 怎么了? 谢谢。 预计到达时间:多亏了我收到的答案,我现在有了以下内容: 在fileA.h中,我有 在fileA.c中,我有 在fileB.h中,我有 在fileB.cpp中,我有 但是,我现在有错误 问题答案: 如果您确实是使用C而不是C

  • 问题内容: 我正在尝试使用mingw的gcc与我的MSVC构建的python26_d一起运行Rabbyt库的调试版本。我有很多未定义的引用,这导致我创建了libpython26_d.a,但是仍然存在一个未定义的引用。谷歌搜索给我: http://www.techlists.org/archives/programming/pythonlist/2003-03/msg01035.shtml 但是-r

  • 如有任何线索将不胜感激。 换了cmakelists后我又遇到了一个问题