[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/

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 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 -lm 
gcc -Wall -O2 -Wl,-static -o swish-e swish.o keychar_out.o dump.o 
result_output.o  ./.libs/libswishindex.a /usr/lib/ -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

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

I don't really grok libtool well enough to understand why libxml2 is
listed specifically as a .so.

In my I set:

    LIBXML2_LIB="`$XML2_CONFIG --libs`"
    LIBXML2_CFLAGS="`$XML2_CONFIG --cflags`"

and in my 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) gets generated with this line:

# Libraries that this one depends upon.
dependency_libs=' -L/usr/lib /usr/lib/ -lpthread -lz -lm  '

I guess what I'd like to be able to do is simply:

  ./configure --static

Thanks for the pointers,

Bill Moseley

reply via email to

[Prev in Thread] Current Thread [Next in Thread]