15074 – g++ -lsupc++ still links against libstdc++ (original) (raw)

Description James A. Morrison 2004-04-22 16:06:13 UTC

The FAQ says that using g++ and -lsupc++ together will link against libsupc++ instead of libstdc++. This doesn't work on GNU/Linux:

jim@squirrel:/test $ g++ -o sizeof sizeof.cc -lsupc++ jim@squirrel:/test $ ldd sizeof libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x7002c000) libm.so.6 => /lib/libm.so.6 (0x700f0000) libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0x70184000) libc.so.6 => /lib/libc.so.6 (0x701a0000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x70000000) jim@squirrel:/test $ gcc -o sizeof sizeof.cc -lsupc++ jim@squirrel:/test $ ldd sizeof libc.so.6 => /lib/libc.so.6 (0x7002c000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x70000000)

Comment 2 Drea Pinski 2004-04-22 16:19:59 UTC

If the only functions from libstdc++.a which you need are language support functions (those listed in
clause 18 of the standard, e.g., new and delete), then try linking against libsupc++.a (usually specifying -lsupc++ when calling g++ for the final link step will do it). This library contains only those support routines, one per object file. But if you are using anything from the rest of the library, such as IOStreams or vectors, then you'll still need pieces from libstdc++.a.

It does say to use g++ though :( This should change.

Comment 3 James A. Morrison 2004-04-22 16:30:57 UTC

Created attachment 6137 [details] A c program that shouldn't use anything from libstdc++

For completeness this is the program I tried with g++ and g++ -lsupc++

Comment 4 Benjamin Kosnik 2004-05-13 04:39:50 UTC

Indeed, what FAQ?

You need to be using gcc, not g++ to do this kind of thing. ie:

gcc -o sizeof sizeof.cc -lsupc++

-benjamin

Comment 7 Benjamin Kosnik 2004-05-13 15:16:08 UTC

This is a documentation error, now fixed.

Comment 9 Drea Pinski 2004-05-14 12:26:02 UTC

Fixed for 3.4.1.