繁体   English   中英

使用G ++增强静态链接问题

[英]Boost static linking issue with G++

我有一个应用程序,所有的动态链接都可以,但是当我尝试使用静态链接进行编译时,出现以下错误。

我的应用使用了Boost线程Asio

错误:

/tmp/ccMj2fHI.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x237): undefined reference to `boost::system::get_system_category()'
test.cpp:(.text+0x243): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x24f): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x25b): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x267): undefined reference to `boost::system::get_system_category()'
/tmp/ccnCWj1O.o: In function `__static_initialization_and_destruction_0(int, int)':
AccountSe.cpp:(.text+0x507): undefined reference to `boost::system::get_system_category()'
AccountSe.cpp:(.text+0x513): undefined reference to `boost::system::get_generic_category()'
AccountSe.cpp:(.text+0x51f): undefined reference to `boost::system::get_generic_category()'
AccountSe.cpp:(.text+0x52b): undefined reference to `boost::system::get_generic_category()'
AccountSe.cpp:(.text+0x537): undefined reference to `boost::system::get_system_category()'

以及所有源文件的类似错误。

编译命令行:

g ++ -L / usr / lib / -lboost_system -lboost_thread -o newserver -static /usr/lib/libboost_thread.a /usr/lib/libboost_system.a stdafx.cpp test.cpp AccountSe.cpp ... -lpthread -std = C ++ 0x

很有可能是由于您的链接顺序。 Boost库首先出现在命令行中,并且在处理它们之后,链接器将丢弃未引用的符号,然后继续链接其他目标文件和库。

源代码之后和-lpthread之前放置boost库。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM