G ++未定义的引用`的boost ::系统:: system_category() [英] g++ undefined reference to `boost::system::system_category()'

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

问题描述

我已搜查高和低的回答这个问题。我使用升压1.48,程序是非常简单的,因为我已经为了解决这个问题打破它归结为最简单的形式。

I have searched high and low for answer to this issue. I am using boost 1.48 and the program is extremely simple, since I have broken it down to its simplest form in order to solve this issue.

#include <boost/filesystem.hpp>

int main(int argc, char **argv) {
    return 0;
}

++命令从我的Makefile文件执行的g是如下:

The g++ command executed from my Makefile is as follows:

g++ -m32 -Wall -o mapnik-test -L/usr/lib -I/usr/include -I/usr/include/freetype2 -lpthread -lboost_system mapnik-test.cpp

错误的连接过程中的完整列表如下:

The complete list of errors during linking is as follows:

/tmp/ccIbmuee.o: In function `__static_initialization_and_destruction_0(int, int)':
mapnik-test.cpp:(.text+0x49): undefined reference to `boost::system::generic_category()'
mapnik-test.cpp:(.text+0x53): undefined reference to `boost::system::generic_category()'
mapnik-test.cpp:(.text+0x5d): undefined reference to `boost::system::system_category()'
collect2: ld returned 1 exit status
make: *** [mapnik-test] Error 1

我发现有很多人从同一个问题的痛苦,但在大多数情况下,该解决方案是提供一种在LDFLAGS的boost_system库。你可以从g ++命令行看到,我已经有这个规定。我甚至试图连接明确反对libboost_system.a库无济于事。我是唯一拥有此投诉?

I have found many people suffering from the same issue, but in most cases, the solution has been to provide the boost_system library in the LDFLAGS. As you can see from the g++ command line, I already have this specified. I have even tried explicitly linking against the libboost_system.a library to no avail. Am I the only person with this complaint?

推荐答案

把源文件在命令行的开头。

Put the source file at the beginning of the command line.

尝试

g++ -m32 -Wall mapnik-test.cpp -o mapnik-test -L/usr/lib -I/usr/include -I/usr/include/freetype2 -lpthread -lboost_system

该库只在源文件后指定,使连接器可以解析源文件中的未定义的引用。

The libraries should be specified only after the source file so that the linker can resolve the undefined references in the source file.

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

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