Overview
Features
Download
Documentation
Community
Add-Ons & Services

poco c++ static linking problems with undefined references

Please post support and help requests here.

poco c++ static linking problems with undefined references

Postby gregee123 » 29 Mar 2013, 13:13

Hello

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&)
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
gregee123
 
Posts: 64
Joined: 29 Mar 2013, 12:11

Re: poco c++ static linking problems with undefined referenc

Postby alex » 29 Mar 2013, 19:14

gregee123 wrote: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

It's the order of libraries.
Try moving foundation to the end:
Code: Select all
g++ BCCMain.o -L$_POCO_LIBS -Wl,-Bstatic $_POCO_LIBS/libPocoUtil.a $_POCO_LIBS/libPocoXML.a $_POCO_LIBS/libPocoJSON.a $_POCO_LIBS/libPocoFoundation.a -Wl,-Bdynamic -o BCMain
alex
 
Posts: 1158
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: poco c++ static linking problems with undefined referenc

Postby gregee123 » 29 Mar 2013, 21:12

Thank you. That was easy enough.

Can you tell me what's the general rule as far as the order of static libs?
currently using: 1.5.4
gregee123
 
Posts: 64
Joined: 29 Mar 2013, 12:11

Re: poco c++ static linking problems with undefined referenc

Postby alex » 29 Mar 2013, 21:20

gregee123 wrote:Can you tell me what's the general rule as far as the order of static libs?

http://lmgtfy.com/?q=gcc+static+order+link+libs
alex
 
Posts: 1158
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests