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

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

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

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

Compiler : Gcc
Program code: Only tried inlcuding the above file system operations.hpp file.

从代码块生成日志(log):

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_系统

Linux相关问答推荐

无法下载Centos 7上的存储库的元数据

Linux在所有多行中用新值替换整个列

使用文件名重新打开 linux 管道(仅从一侧)

如何在不进行轮询且不吃掉其他人子进程的退出代码的情况下等待一组子进程(并且只有它们)?

为什么控制台不接受反向换行?

如何使用 shell 脚本将文本文件转换为 JSON 文件

获取S3路径的linux命令

Linux合并文件

如何将输出从 grep 传送到 cp?

我如何从 Ubuntu 上的源代码自己构建 python?

如何在 Linux 中通过控制台输出启动 Tomcat?

如何使用 Ansible 等待服务器重启?

qstat 和长作业(job)名称

使用 C++ 和 Linux 的高分辨率计时器?

如何等待第一个命令完成?

crt1.o:在函数_start中:-Linux 中未定义对main的引用

是否有git sed或类似功能?

后缀 - status=bounced(未知用户myuser)

将默认 Python 版本从 2.4 更改为 2.6

如何安排 tcpdump 在特定时间段内运行?