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: Gcc static linking problems


Thanks everyone for the help. However, it is still not working properly.


By changing the order around like Meng and Claudio suggested I was able
to get the application to compile and link. The problem is that it did
not link statically.

Is there something in gcc that could change the link defaults? Or is
this a Solaris issue?

Thanks,

Tim

-----Original Message-----
From: Meng-Hsueh Chiang [mailto:mhchiang@mail.com] 
Sent: Monday, August 11, 2003 8:11 PM
To: Tim Purkerson
Cc: gcc-help@gcc.gnu.org
Subject: Re: Gcc static linking problems






> If I use the exact source code and makefile everything works great 
> except it builds the application to use dynamic linking. This becomes 
> a problem when our customer's systems don't have the libraries this 
> application needs (libstdc++ specifically).
> 
> So, the obvious solution is to build it statically, but I can't get it

> to build. There are error messages about unresolved externals that 
> should be resolved in the libsocket library.
> 
> 
> 2. I have seen a lot of posts about adding -static to the build line 
> and even alternating static and dynamic to get it to build correctly. 
> I have tried many combination of this with no success. What am I doing

> wrong on this line?
> 	g++ -lnsl -lsocket program.o -o program -static -lstdc++
> 

Can you try 
g++ -o program program.o -Bstatic -lstdc++  -Bdynamic -lsocket -lnsl

(The order is important as Claudio said in earlier reply)
I guess the default is dynamic, so you'd need to add -dynamic after
-static assuming you only want to link -lstdc++ statically and others
dynamically. Can you also check your .cshrc(?) and make sure there is no
LD_OPTIONS set. Hope it helps.

Meng


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