C++ Boost:对 boost::system::generic_category() 的未定义引用 [英] C++ Boost: undefined reference to boost::system::generic_category()
问题描述
我正在尝试在我的项目中包含 Boost
库,并且一直面临着同样的问题.我在 Ubuntu 12.10 上使用 Codeblocks IDE,并尝试手动安装库,从站点读取指令,但在使用头文件和使用前要构建的库时遇到错误.
I am trying to include Boost
libraries in my project and have been facing issues in the same. I am on Ubuntu 12.10 with Codeblocks IDE and tried installing the libraries manually reading instructions from the site, but was getting error's with header as well as to-be-built-before-use libraries.
然后我通过终端通过 sudo apt-get install libboost-all-dev
安装了这些库.在此之后,在我的代码块程序中,我可以包含像 #include <boost/regex.hpp>
这样的头文件,但是当我尝试包含文件系统库的头文件时 ( #include "boost/filesystem/operations.hpp"
),我收到以下错误:
I then installed the libraries via terminalby sudo apt-get install libboost-all-dev
. After this, in my programs on Codeblocks, I can include headers like #include <boost/regex.hpp>
but when I try to include the header for the Filesystem library ( #include "boost/filesystem/operations.hpp"
), I am getting the following error:
/usr/include/boost/system/error_code.hpp|214|undefined reference to boost::system::generic_category()'|
我不知道如何解决这个错误(特别是在 Linux 上的代码块中).我真的可以在这里得到一些帮助.
I am not sure how to resolve this error (specifically in Codeblocks on Linux). I really could use some help here.
编译器: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++ 命令行选项是
You should link in the libboost_system
library. I am not sure about codeblocks, but the g++ command-line option on your platform would be
-lboost_system
-lboost_system
这篇关于C++ Boost:对 boost::system::generic_category() 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!