On Wed, 1 May 2002, mike ledoux <[EMAIL PROTECTED]> wrote:
> 
> > I downloaded a source package that I need to compile statically so I 
> > can move the binary to another machine which does not have all the 
> > necessary packages.  How do I do that?
> 
> > The package comes with the standard gnu autoconf configure script, 
> > but I didn't see anything in there or in the resultant Makefile to 
> > indicate a static build.
> 
> Typically adding '-static' to the linker options is enough.  Often adding
> '--enable-static=yes' to your configure command line does this for you,
> but not always.

I would suggest not statically linking the whole executable, but rather
just statically link in only the archive libraries (.a's) you do not
expect to be on the target machines (as shared objects .so's).

I say this because if you statically link in the low-level libraries
(libc, libnsl, ...) then that executable has a higher chance of
breaking down the road, the reason being you've statically bolted
libc.a into it, and that code may become out of sync with the
system/kernel at a later date.  Better to use the shared object
libc.so.6 that has a good chance of shielding you from changes in the
system.

Off the top of my head, with gcc the only way I know how to do this is
to change the final cc/link line from something like:

    cc -o theprogram ... -lX11 -ltheywonthaveit -lgtk -lglib

to have the full path to the .a archive:

    cc -o theprogram ... -lX11 /usr/local/lib/libtheywonthaveit.a -lgtk -lglib

With other compilers you can turn on and off with -Bstatic and -Bdynamic
(for example) and sandwich the -ltheywonthaveit with them.

Also, for Linux/GLIBC I don't know why but its /usr/lib/libc.a is
insanely huge.  30MB for libc.a vs 1MB for libc.so.6.  You likely won't
statically link in all of libc.a... but what you do link in will fatten
up the executable quite a bit, wasting disk space and RAM.


*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to