gpt4 book ai didi

C++ Boost:对 boost::system::generic_category() 的 undefined reference

转载 作者:太空宇宙 更新时间:2023-11-04 13:23:30 26 4
gpt4 key购买 nike

我正在尝试包括 Boost我项目中的库,并且一直面临同样的问题。我在带有 Codeblocks IDE 的 Ubuntu 12.10 上,并尝试手动安装库,从站点读取说明,但在 header 和使用前构建的库中出现错误。

然后我通过终端安装库 sudo apt-get install libboost-all-dev .在此之后,在我的 Codeblocks 程序中,我可以包含像 #include <boost/regex.hpp> 这样的标题。但是当我尝试包含文件系统库 ( #include "boost/filesystem/operations.hpp" ) 的 header 时,出现以下错误:

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

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

编译器:Gcc
程序代码: 仅尝试包含上述文件系统operations.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

最佳答案

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

-lboost_system

关于C++ Boost:对 boost::system::generic_category() 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34155210/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com