public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Static linking to libgcc_s and libstdc++
@ 2002-08-04 17:21 John Carter
  2002-08-04 22:41 ` bjorn rohde jensen
  0 siblings, 1 reply; 3+ messages in thread
From: John Carter @ 2002-08-04 17:21 UTC (permalink / raw)
  To: gcc-help

Greetings folk,

I have just compiled gcc-3.1.1 for Solaris 2.5.1.

I have compiled my app, and now wish to distribute it to the test machines 
/ clients.

Alas, it expects a sharable libstdc++ and libgcc_s.

I can distribute the .so files as well, but this increases maintenance and 
customer support headaches.

How can I convince gcc to statically link in those libraries (and no other 
sharable libraries)?

Thank you,

-- 


John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter@tait.co.nz
New Zealand

This email message is intended only for the addressee(s) and contains
information which may be confidential and/or copyright.  If you are not
the intended recipient please do not read, save, forward, disclose, or
copy the contents of this email. If this email has been sent to you in
error, please notify the sender by reply email and he will be
along to delete you, this email and any copies or links to this email.  
No representation is made that this email, you, or the sender are free of
viruses. Virus scanning and prevention is recommended and is the
responsibility of consenting adults.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Static linking to libgcc_s and libstdc++
  2002-08-04 17:21 Static linking to libgcc_s and libstdc++ John Carter
@ 2002-08-04 22:41 ` bjorn rohde jensen
  0 siblings, 0 replies; 3+ messages in thread
From: bjorn rohde jensen @ 2002-08-04 22:41 UTC (permalink / raw)
  To: John Carter; +Cc: gcc-help

Hi John,

 In the past i have passed link options through gcc/g++
to the platform linker to do this sort of thing by means
of -Wl,option1,option2.... The idea is to switch to static
linking before the -l option for the lib, you want to link
to statically, and back to shared linking after it.
 Depending on what combination of shared/static libs you
want to use, you might need to tell gcc not to implicitly
link with its libs with the -nostdlib and do that manually.

Yours sincerely,

Bjorn

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Static linking to libgcc_s and libstdc++
       [not found] <616BE6A276E3714788D2AC35C40CD18D762A3B@whale.softwire.co.uk>
@ 2002-08-05  6:24 ` Rupert Wood
  0 siblings, 0 replies; 3+ messages in thread
From: Rupert Wood @ 2002-08-05  6:24 UTC (permalink / raw)
  To: 'John Carter'; +Cc: gcc-help

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-05 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-04 17:21 Static linking to libgcc_s and libstdc++ John Carter
2002-08-04 22:41 ` bjorn rohde jensen
     [not found] <616BE6A276E3714788D2AC35C40CD18D762A3B@whale.softwire.co.uk>
2002-08-05  6:24 ` Rupert Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).