Re: Gcc static linking problems

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

 



On Mon, Aug 11, 2003 at 02:25:52PM -0700, Tim Purkerson wrote:
> Here are the questions:
> 1. Is there any reason why we shouldn't be trying to build it
> statically? How could we make sure our customers have the necessary
> libraries if we do build it dynamically? 

Static linking is certainly a simple way to make sure the application
is runnable on the user's system. The downside being the bigger size
and memory footprint.

When dynamically linking you could distribute all the needed libraries
with your application and with some magical dlopen'ing or whatever
Solaris uses if the library can't be found on the user's system; use
the version shipped with the application. However, I've never done
that -- so take this advice with a grain of salt...

> 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++

When statically linking the order of libraries and object files on 
GCC's command line usually is significant. Try

	g++ program.o -o program -lnsl -lsocket -static -lstdc++ 

> 3. Is this problem caused by gcc or by Solaris or by the user?

I'd say in this case it's a user problem. 


HTH
-- 
Claudio Bley                                 ASCII ribbon campaign (")
Debian GNU/Linux user                         - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \


[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