RE: Gcc static linking problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx] 
Sent: Monday, August 11, 2003 8:11 PM
To: Tim Purkerson
Cc: gcc-help@xxxxxxxxxxx
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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux