未定义的引用'boost :: system :: generic_category()'? [英] Undefined reference to 'boost::system::generic_category()'?

查看:3838
本文介绍了未定义的引用'boost :: system :: generic_category()'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我无法看到明显的。我想为我的项目使用一些Boost库功能,并且知道我突然得到这些错误:

it seems that i am unable to see the obvious. I wanted to use some Boost library features for my project and know i am getting these nice errors all of a sudden:


链接CXX可执行文件
CMakeFiles / ATFOR.dir / stdafx.cc.o:在函数 __ static_initialization_and_destruction_0(int,int)':
stdafx.cc:(.text+0x3c):未定义引用 boost :: system :: generic_category()$ boost $ system $($)
stdafx.cc:(text + 0x48):未定义引用< '
stdafx.cc:(.text+0x54):未定义的引用
boost :: system :: system_category()'
CMakeFiles / ATFOR.dir / Main.cc。 o:在函数 __ static_initialization_and_destruction_0(int,int)':
Main.cc:(.text+0x29d):未定义的引用
boost :: system :: generic_category ()'
Main.cc:(.text+0x2a9):未定义的引用 boost :: system :: generic_category()'
Main.cc:(.text+0x2b5 ):未定义引用
boost :: system :: system_category()'
collect2:error:ld返回1退出状态

Linking CXX executable ATFOR CMakeFiles/ATFOR.dir/stdafx.cc.o: In function __static_initialization_and_destruction_0(int, int)': stdafx.cc:(.text+0x3c): undefined reference toboost::system::generic_category()' stdafx.cc:(.text+0x48): undefined reference to boost::system::generic_category()' stdafx.cc:(.text+0x54): undefined reference toboost::system::system_category()' CMakeFiles/ATFOR.dir/Main.cc.o: In function __static_initialization_and_destruction_0(int, int)': Main.cc:(.text+0x29d): undefined reference toboost::system::generic_category()' Main.cc:(.text+0x2a9): undefined reference to boost::system::generic_category()' Main.cc:(.text+0x2b5): undefined reference toboost::system::system_category()' collect2: error: ld returned 1 exit status

在这里,您可以找到我的CMakeLists.txt,标题和主要内容: http://pastie.org/8231509

正如你可以看到的,我试着很多玩CMakeLists,我很肯定,我有我的项目需要的所有标题。无论如何,我从来没有这样的错误,我真的很感激任何建议/解决方案,这里有什么问题,因为我现在还没有任何想法。 。

Here you find my CMakeLists.txt, headers, and main: http://pastie.org/8231509
As you can see, i tried a lot playing around with the CMakeLists and i am pretty sure that i have all headers my project requires. Anyways, i've never had such errors before and i really appreciate any suggestions/solutions about what's wrong here since i don't have any ideas left for now. Thx in advance.

推荐答案

您必须明确添加要链接到您的程序的系统库

You must explicitly add the system library for it to be linked into your program

find_package(Boost REQUIRED COMPONENTS system)
#                                      ^^^^^^ this :)

对于单独构建的其他Boost库(正则表达式,线程等)也必须这样做(请参阅此处)。

This must also be done for other Boost libraries that are built separately (regex, thread, etc.) (see here).

这篇关于未定义的引用'boost :: system :: generic_category()'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆