[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Building completely static program
From: |
Bill Moseley |
Subject: |
Building completely static program |
Date: |
Tue, 18 May 2004 13:35:24 -0700 |
User-agent: |
Mutt/1.5.5.1+cvs20040105i |
I'm wondering how to build a static binary.
I tried using:
./configure -disable-shared CCFLAGS=LDFLAGS="-Wl,-static" CFLAGS=-O2
but my program links with libxml2, so when linking I still see:
(notice how libxml2.so is listed)
/bin/sh ../libtool --mode=link gcc -Wall -O2 -Wl,-static -o swish-e swish.o
keychar_out.o dump.o result_output.o libswishindex.la libswish-e.la -lm
gcc -Wall -O2 -Wl,-static -o swish-e swish.o keychar_out.o dump.o
result_output.o ./.libs/libswishindex.a /usr/lib/libxml2.so -lpthread
./.libs/libswish-e.a -lz -lm
I assume that .so listing prevents building the binary static. I'm able
to build a static binary by running this directly (notice -lxml2
instead):
gcc -Wall -O2 -Wl,-static -o swish-e swish.o keychar_out.o dump.o
result_output.o ./.libs/libswishindex.a -lxml2 -lpthread ./.libs/libswish-e.a
-lz -lm
Does libtool deal specially with libxml2? I noticed that xml2-config
has a special option for libtool.
$ xml2-config --libtool-libs
/usr/lib/libxml2.la
I don't really grok libtool well enough to understand why libxml2 is
listed specifically as a .so.
In my configure.in I set:
LIBXML2_LIB="`$XML2_CONFIG --libs`"
LIBXML2_CFLAGS="`$XML2_CONFIG --cflags`"
and in my Makefile.am I use those as:
AM_CPPFLAGS = -Dlibexecdir=\"${libexecdir}\" \
-DPATH_SEPARATOR=\"${PATH_SEPARATOR}\" \
$(Z_CFLAGS) $(PCRE_CFLAGS) $(LIBXML2_CFLAGS) -Ireplace
libswishindex_la_LDFLAGS = $(LIBXML2_LIB) $(Z_LIBS) $(PCRE_LIBS)
libswishindex.la gets generated with this line:
# Libraries that this one depends upon.
dependency_libs=' -L/usr/lib /usr/lib/libxml2.la -lpthread -lz -lm '
I guess what I'd like to be able to do is simply:
./configure --static
Thanks for the pointers,
--
Bill Moseley
address@hidden
- Building completely static program,
Bill Moseley <=