This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Static linking to libgcc_s and libstdc++


John Carter wrote:

> Alas, it expects a sharable libstdc++ and libgcc_s.
:
> How can I convince gcc to statically link in those libraries
> (and no other sharable libraries)?

I'm on shaky ground here - I'm no ld expert - but:

   gcc <objects> -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic <rest of libs>

This should work with GNU ld but I've only tried it using Solaris ld.

Note that you're explicitly breaking GCC's C++ model object model: all
C++ binaries and shared libraries link in libgcc_s so that they all use
the same binary copy of the exception handling mechanism. If, however,
all C++ code is in your executable and all dynamic libraries are plain C
then you should get away with linking these statically.

Since you have to link libstdc++ explicitly yourself, you should use the
gcc driver and not the g++ driver. Combined with linking it before any
other libraries, this should enforce the plain-C-libraries-only
requirement at link time.

Good luck,
Rup.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]