Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

poco c++ static linking problems with undefined references to symbols

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

like image 565
gregee123 Avatar asked Mar 29 '13 10:03

gregee123


1 Answers

My experience is that the order of linking the Poco libraries is important when statically linked. Seems important Foundation to be the last one.

The order that works for me is:

  1. Util
  2. Net
  3. XML
  4. Foundation
like image 180
i_papp Avatar answered Oct 13 '22 11:10

i_papp