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

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

问题描述

我已经搜索了很多关于这个问题的答案.我使用的是 boost 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::system_category()' 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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