public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* g++ -static-libgcc not working (g++ 3.0.4).
@ 2002-09-05  5:51 jean-frederic clere
  2002-09-05  8:00 ` Phil Edwards
  0 siblings, 1 reply; 7+ messages in thread
From: jean-frederic clere @ 2002-09-05  5:51 UTC (permalink / raw)
  To: gcc

Hi,

I am on a Solaris machine (5.8) and I am not using the gnu ld.
I am trying to have a program linked staticly with libstdc++.a and libgcc.a.

I have tried g++ -o program -static-libgcc ...
But program still requires libstdc++.so.3 and libgcc_s.so.1

I have tried to -static but it failed because g++ does find  dlopen and relatives.

Any ideas about what could be wrong?

Cheers

Jean-frederic


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

* Re: g++ -static-libgcc not working (g++ 3.0.4).
  2002-09-05  5:51 g++ -static-libgcc not working (g++ 3.0.4) jean-frederic clere
@ 2002-09-05  8:00 ` Phil Edwards
  2002-09-05  9:28   ` jean-frederic clere
  0 siblings, 1 reply; 7+ messages in thread
From: Phil Edwards @ 2002-09-05  8:00 UTC (permalink / raw)
  To: jean-frederic clere; +Cc: gcc

On Thu, Sep 05, 2002 at 02:06:39PM +0200, jean-frederic clere wrote:
> Hi,
> 
> I am on a Solaris machine (5.8) and I am not using the gnu ld.
> I am trying to have a program linked staticly with libstdc++.a and libgcc.a.
> 
> I have tried g++ -o program -static-libgcc ...
> But program still requires libstdc++.so.3 and libgcc_s.so.1
> 
> I have tried to -static but it failed because g++ does find  dlopen and relatives.
> 
> Any ideas about what could be wrong?

Specify static linking for just the libraries you want statically linked,
and then revert to dynamic libraries for the rest.  See the ld(1) man page
for -Bstatic and -Bdynamic.

-- 
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
                                                 - Edsger Dijkstra, 1930-2002

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

* Re: g++ -static-libgcc not working (g++ 3.0.4).
  2002-09-05  8:00 ` Phil Edwards
@ 2002-09-05  9:28   ` jean-frederic clere
  2002-09-05  9:36     ` Phil Edwards
  0 siblings, 1 reply; 7+ messages in thread
From: jean-frederic clere @ 2002-09-05  9:28 UTC (permalink / raw)
  To: Phil Edwards; +Cc: gcc

Phil Edwards wrote:
> On Thu, Sep 05, 2002 at 02:06:39PM +0200, jean-frederic clere wrote:
> 
>>Hi,
>>
>>I am on a Solaris machine (5.8) and I am not using the gnu ld.
>>I am trying to have a program linked staticly with libstdc++.a and libgcc.a.
>>
>>I have tried g++ -o program -static-libgcc ...
>>But program still requires libstdc++.so.3 and libgcc_s.so.1
>>
>>I have tried to -static but it failed because g++ does find  dlopen and relatives.
>>
>>Any ideas about what could be wrong?
> 
> 
> Specify static linking for just the libraries you want statically linked,
> and then revert to dynamic libraries for the rest.  See the ld(1) man page
> for -Bstatic and -Bdynamic.
> 

Calling ld directly with -Bstatic -lgcc -lstdc++ -Bdynamic -lc works but there 
seems to be noway to do it directly from g++.

The g++ -static-libgcc gives something like:
+++
  /opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/collect2 -V -Y 
P,/usr/ccs/lib:/usr/lib -Qy -o htdig 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crt1.o 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crti.o 
/usr/ccs/lib/values-Xa.o 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crtbegin.o -L../htlib 
-L../htcommon -L../db/dist -L/usr/lib 
-L/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4 
-L/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/../../../../sparc-sun-solaris2.8/lib 
-L/usr/ccs/bin -L/usr/ccs/lib 
-L/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/../../.. Document.o 
HTML.o Images.o Parsable.o Plaintext.o Retriever.o SGMLEntities.o Server.o 
URLRef.o htdig.o ExternalParser.o PDF.o ../htcommon/libcommon.a ../htlib/libht.a 
../db/dist/libdb.a -lz -lnsl -lsocket -lstdc++ -lm -lgcc -lc -lgcc 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crtend.o 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crtn.o
+++
When I am doing:
+++
g++ -v -o htdig -static-libgcc -L../htlib -L../htcommon -L../db/dist -L/usr/lib
Document.o HTML.o Images.o  Parsable.o Plaintext.o  Retriever.o SGMLEntities.o 
Server.o  URLRef.o htdig.o ExternalParser.o PDF.o ../htcommon/libcommon.a 
../htlib/libht.a  ../db/dist/libdb.a \
-lz -lnsl -lsocket
+++

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

* Re: g++ -static-libgcc not working (g++ 3.0.4).
  2002-09-05  9:28   ` jean-frederic clere
@ 2002-09-05  9:36     ` Phil Edwards
  2002-09-05 10:03       ` jean-frederic clere
  0 siblings, 1 reply; 7+ messages in thread
From: Phil Edwards @ 2002-09-05  9:36 UTC (permalink / raw)
  To: jean-frederic clere; +Cc: gcc

On Thu, Sep 05, 2002 at 06:30:28PM +0200, jean-frederic clere wrote:
> Phil Edwards wrote:
> > 
> > Specify static linking for just the libraries you want statically linked,
> > and then revert to dynamic libraries for the rest.  See the ld(1) man page
> > for -Bstatic and -Bdynamic.
> 
> Calling ld directly with -Bstatic -lgcc -lstdc++ -Bdynamic -lc works but there 
> seems to be noway to do it directly from g++.

See the GCC manual.  Look for -Wl.

-- 
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
                                                 - Edsger Dijkstra, 1930-2002

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

* Re: g++ -static-libgcc not working (g++ 3.0.4).
  2002-09-05  9:36     ` Phil Edwards
@ 2002-09-05 10:03       ` jean-frederic clere
  2002-09-05 10:08         ` Phil Edwards
  0 siblings, 1 reply; 7+ messages in thread
From: jean-frederic clere @ 2002-09-05 10:03 UTC (permalink / raw)
  To: Phil Edwards; +Cc: gcc

Phil Edwards wrote:
> On Thu, Sep 05, 2002 at 06:30:28PM +0200, jean-frederic clere wrote:
> 
>>Phil Edwards wrote:
>>
>>>Specify static linking for just the libraries you want statically linked,
>>>and then revert to dynamic libraries for the rest.  See the ld(1) man page
>>>for -Bstatic and -Bdynamic.
>>
>>Calling ld directly with -Bstatic -lgcc -lstdc++ -Bdynamic -lc works but there 
>>seems to be noway to do it directly from g++.
> 
> 
> See the GCC manual.  Look for -Wl.
> 

But that did not help because g++ puts -lgcc -lstdc++ after my:
-Wl,"-Bstatic" -lstdc++ -lgcc -Wl,"-Bdynamic"

+++
  /opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/collect2 -V -Y 
P,/usr/ccs/lib:/usr/lib -Qy -o htdig 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crt1.o 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crti.o 
/usr/ccs/lib/values-Xa.o 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crtbegin.o -L../htlib 
-L../htcommon -L../db/dist -L/usr/lib 
-L/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4 
-L/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/../../../../sparc-sun-solaris2.8/lib 
-L/usr/ccs/bin -L/usr/ccs/lib 
-L/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/../../.. Document.o 
HTML.o Images.o Parsable.o Plaintext.o Retriever.o SGMLEntities.o Server.o 
URLRef.o htdig.o ExternalParser.o PDF.o ../htcommon/libcommon.a ../htlib/libht.a 
../db/dist/libdb.a -lz -lnsl -lsocket -Bstatic -lstdc++ -lgcc -Bdynamic -lstdc++ 
-lm -lgcc -lc -lgcc 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crtend.o 
/opt/SMAWPlus/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/crtn.o
+++

BTW why "-lgcc -lc -lgcc", something wrong in the configure of gcc?

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

* Re: g++ -static-libgcc not working (g++ 3.0.4).
  2002-09-05 10:03       ` jean-frederic clere
@ 2002-09-05 10:08         ` Phil Edwards
  2002-09-06  1:55           ` jean-frederic clere
  0 siblings, 1 reply; 7+ messages in thread
From: Phil Edwards @ 2002-09-05 10:08 UTC (permalink / raw)
  To: jean-frederic clere; +Cc: gcc

On Thu, Sep 05, 2002 at 07:06:19PM +0200, jean-frederic clere wrote:
> But that did not help because g++ puts -lgcc -lstdc++ after my:
> -Wl,"-Bstatic" -lstdc++ -lgcc -Wl,"-Bdynamic"

The libraries are searched in the order that they are listed.

> BTW why "-lgcc -lc -lgcc", something wrong in the configure of gcc?

Nope.  That's normal.  (Libraries are searched in the order that they
are listed.  libgcc creates a references to something needed from libc,
and in fulfilling that requirement, libc needs something from libgcc that
wasn't needed previously.)

-- 
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
                                                 - Edsger Dijkstra, 1930-2002

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

* Re: g++ -static-libgcc not working (g++ 3.0.4).
  2002-09-05 10:08         ` Phil Edwards
@ 2002-09-06  1:55           ` jean-frederic clere
  0 siblings, 0 replies; 7+ messages in thread
From: jean-frederic clere @ 2002-09-06  1:55 UTC (permalink / raw)
  To: Phil Edwards; +Cc: gcc

Phil Edwards wrote:
> On Thu, Sep 05, 2002 at 07:06:19PM +0200, jean-frederic clere wrote:
> 
>>But that did not help because g++ puts -lgcc -lstdc++ after my:
>>-Wl,"-Bstatic" -lstdc++ -lgcc -Wl,"-Bdynamic"
> 
> 
> The libraries are searched in the order that they are listed.

So I would except that the -static-libgcc do a:
-Bstatic -lstdc++ -Bdynamic -lm -Bstatic -lgcc -Bdynamic -lc -Bstatic
-lgcc
instead of:
-lstdc++ -lm -lgcc -lc -lgcc

BTW To get the link done I have to give the -lm option twice because the first 
one is ignored (the same for -lc)
+++
g++ -v -o htdig -static-libgcc -L../htlib -L../htcommon -L../db/dist -L/usr/lib
Document.o HTML.o Images.o  Parsable.o Plaintext.o  Retriever.o SGMLEntities.o 
Server.o  URLRef.o htdig.o ExternalParser.o PDF.o ../htcommon/libcommon.a 
../htlib/libht.a  ../db/dist/libdb.a \
-lz -lnsl -lsocket \
-Wl,"-Bstatic" \
-lstdc++ -Wl,"-Bdynamic" -lm -lm -Wl,"-Bstatic" \
-lgcc \
-Wl,"-Bdynamic" \
-lc -lc \
-Wl,"-Bstatic" \
-lgcc
+++

> 
> 
>>BTW why "-lgcc -lc -lgcc", something wrong in the configure of gcc?
> 
> 
> Nope.  That's normal.  (Libraries are searched in the order that they
> are listed.  libgcc creates a references to something needed from libc,
> and in fulfilling that requirement, libc needs something from libgcc that
> wasn't needed previously.)
> 



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

end of thread, other threads:[~2002-09-06  8:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-05  5:51 g++ -static-libgcc not working (g++ 3.0.4) jean-frederic clere
2002-09-05  8:00 ` Phil Edwards
2002-09-05  9:28   ` jean-frederic clere
2002-09-05  9:36     ` Phil Edwards
2002-09-05 10:03       ` jean-frederic clere
2002-09-05 10:08         ` Phil Edwards
2002-09-06  1:55           ` jean-frederic clere

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).