[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Building all static
From: |
Bill Moseley |
Subject: |
Re: Building all static |
Date: |
Tue, 2 Nov 2004 06:33:02 -0800 |
User-agent: |
Mutt/1.5.6+20040907i |
On Tue, Nov 02, 2004 at 12:39:10PM +0000, Gary V. Vaughan wrote:
> $ libtool --help --mode=link | grep static
> -all-static do not do any dynamic linking at all
> -static do not do any dynamic linking of libtool libraries
And that seems to work if I place those in my Makefile.am
$ grep -- -static src/Makefile.am
libtest_LDFLAGS = -static
(which maybe answers your question if anyone is using -static)
>
> > 1) The configure option --disable-shared works at linking our binary
> > with our library statically, but still links the binary dynamically
> > with other libraries. I assume that's correct behavior. What does
> > the --enable-static option do (or suppose to do)? It seems to have no
> > effect when I use it.
>
> >From libtool.info(The `AC_PROG_LIBTOOL' macro):
>
> - Macro: AC_DISABLE_STATIC
> - Macro: AM_DISABLE_STATIC
> Change the default behaviour for `AC_PROG_LIBTOOL' to disable
> static libraries. The user may still override this default by
> specifying `--enable-static'.
$ ./configure --help | grep static
--enable-static[=PKGS] build static libraries [default=yes]
I'm not using AC_DISABLE_STATIC in configure -- and using
--enable-static (without listing packages) seems to have no effect.
So do I have something setup incorrectly?
> > 2) Is there a "standard" way to run configure that should build a
> > completely static binary?
>
> Assuming libtool is doing all your linking:
>
> ./configure LDFLAGS='-all-static'
$ ./configure --prefix=$HOME/static LD_FLAGS='-all-static' >/dev/null && make
install >/dev/null
$ ldd $HOME/static/bin/swish-e
libxml2.so.2 => /usr/lib/libxml2.so.2 (0x40027000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x40122000)
libz.so.1 => /usr/lib/libz.so.1 (0x40132000)
libswish-e.so.2 => /home/moseley/static/lib/libswish-e.so.2 (0x40144000)
libm.so.6 => /lib/tls/libm.so.6 (0x4017a000)
libc.so.6 => /lib/tls/libc.so.6 (0x4019d000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
So, does that mean I'm not passing in a variable to my Makefile.am?
http://cvs.sourceforge.net/viewcvs.py/swishe/swish-e/src/Makefile.am?rev=1.12&view=auto
> Does anyone use libtool's -static flag to deliberately link statically
> against libtool libraries only? I would have thought that it is far
> more common to want all-static behaviour.
I'm not really clear on what you are asking, but I use -static in my
Makefile.am to always link a little test program with our library
statically to help with debugging.
$ ldd libtest
libz.so.1 => /usr/lib/libz.so.1 (0x40027000)
libm.so.6 => /lib/tls/libm.so.6 (0x40039000)
libc.so.6 => /lib/tls/libc.so.6 (0x4005d000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
So libswish-e is linked statically there.
> Unless someone shouts me down, then according to the principle of least
> surprise, I'm inclined to change the semantics to:
>
> -static do not do any dynamic linking at all
> -lt-static do not do any dynamic linking of libtool libraries
As long as "libtool libraries" is clear.
--
Bill Moseley
address@hidden
Re: Building all static, Bob Friesenhahn, 2004/11/02
Re: Building all static, Gary V. Vaughan, 2004/11/02