Linking libstdc++.a into a shared library.

Stephen M. Webb stephenw@cryptocard.com
Fri Dec 13 11:11:00 GMT 2002


Something broke an the last few months.

I need to be able to statically link libstdc++.a into one or more shared 
libraries.  Dynamically linking it to a distributable shared library is a 
no-go considering the proprietary nature of Linux distros and the frequent 
ABI changes on all platforms.

Using "-static" on the link line doesn't work because that always links to 
the shared library.

I used to be able to link using the gcc driver and explicitly linking 
libstdc++.a.  This is the method of choice (indeed tho only method on Mac OS 
X, where -static won't work anyway).

Recently, when I've tried this, I get the following.
 
/smw/gnu/lib/gcc-lib/i686-pc-linux-gnu/3.3/../../../../i686-pc-linux-gnu/bin/ld: 
static: undefined versioned symbol name std::time_put_w@@GLIBCPP_3.2
/smw/gnu/lib/gcc-lib/i686-pc-linux-gnu/3.3/../../../../i686-pc-linux-gnu/bin/ld: 
failed to set dynamic section sizes: Bad value

This only happens when using the "-shared" switch and linking in libstdc++.a 
explicitly.  My latest build is gcc version 3.3 20021125 (experimental), but 
the problem also occurs in at least the latest Debian Linux distro of gcc 
(I'm not a Debian user, so I don't know exactly what that means).

So, my questions are,

o  is there a workaround that doesn't involve editing globals.cc and 
rebuilding the library (which won't fly with the other developers here)?

o  will this fix itself in the future so it becomes possible once again to 
link the c++ runtime statically into dynamically loaded libraries?

-- 
Stephen M. Webb
stephenw@cryptocard.com



More information about the Libstdc++ mailing list