libstdc++ linked as libstdc++.a

Christoph Bugel chris@tti-telecom.com
Thu Nov 14 11:44:00 GMT 2002


On 2002-11-14, Stephen M. Webb wrote:
> On November 14, 2002 04:32 am, Christoph Bugel wrote:
[...]
> > linking with -static doesn't work as I expected:
> >
> > Linux$ g++ -fPIC -shared -static hello.cc -o libhello.so
> >
> > Linux$ ldd ./libhello.so
> > 	libstdc++.so.5 => /usr/lib/libstdc++.so.5
> > 	(etc, etc)
> >
> > Do I have to use -nostdinc and pick all libraries by hand or is
> > there an easier way?
> 
> Just explicitly add the libstdc++.a to the list of files to link, like 
> any other library.  No need for -nostdinc.

doesn't work for me:

$ g++ -fPIC -shared -static hello.cc -o libhello.so /usr/lib/libstdc++.a
$ ldd ./libhello.so
        libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x4001f000)
		(etc, etc)

I think I noticed sometime ago that libstdc++.a is compiled without
-fPIC. So even if I convince the g++ frontend to use libstdc++.a, it
could fail at runtime if my target is a shared library.







More information about the Libstdc++ mailing list