poco c++ 静态链接问题与未定义的符号引用 [英] poco c++ static linking problems with undefined references to symbols
问题描述
我正在尝试像这样链接到静态版本的 POCO C++ 库:
I'm trying to link to static versions of the POCO C++ libs like this:
g++ BCCMain.o -L$_POCO_LIBS -Wl,-Bstatic $_POCO_LIBS/libPocoFoundation.a $_POCO_LIBS/libPocoUtil.a $_POCO_LIBS/libPocoXML.a $_POCO_LIBS/libPocoJSON.a -Wl,-Bdynamic -o BCMain
不幸的是,这会导致一些未定义的符号引用错误,例如:
Unfortunatelly this gives errors about some undefined references to symbols like:
Poco::Logger::get(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
即使 Poco::Logger::get(std::string const&)
实际上是在 libPocoFoundation.a
中定义的.
even though Poco::Logger::get(std::string const&)
actually IS defined in libPocoFoundation.a
.
现在,如果我尝试链接到基础库的共享版本,它会起作用:
Now if I try to link to a shared version of the foundation lib it works:
g++ BCCMain.o -L$_POCO_LIBS -Wl,-Bstatic $_POCO_LIBS/libPocoFoundation.a $_POCO_LIBS/libPocoUtil.a $_POCO_LIBS/libPocoXML.a $_POCO_LIBS/libPocoJSON.a -Wl,-Bdynamic -lPocoFoundation -o BCMain
库的静态和共享版本具有相同的符号,所以我发现很难弄清楚我做错了什么.
Static and shared versions of the libs have the same symbols so I find it hard to figure what I'm doing wrong.
Ubuntu/Linaro.g++ 4.6.3
Ubuntu/Linaro. g++ 4.6.3
推荐答案
我的经验是 Poco 库的链接顺序在静态链接时很重要.看起来很重要的 Foundation 是最后一个.
My experience is that the order of linking the Poco libraries is important when statically linked. Seems important Foundation to be the last one.
对我有用的顺序是:
- 实用
- 网络
- XML
- 基础
这篇关于poco c++ 静态链接问题与未定义的符号引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!