Re: How to static link a program?



Le samedi 05 f�ier 2005 �0:40 -0800, Ben Johnson a �it :
> On Sat, Feb 05, 2005 at 06:44:15PM +0100, stian nixia no wrote:
> > > ben elsa:~/Projects/hpntpos$ vi configure.in
> > > ben elsa:~/Projects/hpntpos$ autoconf
> > > configure.in:14: error: possibly undefined macro: AC_ENABLE_STATIC
> > >       If this token and others are legitimate, please use
> > >       m4_pattern_allow.
> > >             See the Autoconf documentation.
> > 
> > aclocal is your friend
> 
> ok.  I edited my configure.in file again and added the two macros.  Then
> ran aclocal.  that increased the size of my aclocal.m4 file by about
> double.  ran autoconf without errors.  did:
> 
> ./configure  --enable-static --disable-dynamic
> 
> without errors, but it did spit out the usual:
> 
> checking PACKAGE_CFLAGS... -DXTHREADS -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
> checking PACKAGE_LIBS... -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
> 
> then ran 'make' and it linked dynamically again.  
> 
> gcc  -g -O2  -o hpntpos  main.o support.o interface.o callbacks.o page_lockedscreen.o page_shiftstart.o page_shiftend.o page_switchboard.o page_cashdrawermngmnt.o page_transactions.o hpnt_log.o access_checking.o signals.o state.o hpnt_db.o hpnt_options.o timer_queue.o window_enter_number_dlg.o window_keyboard_dlg.o hpntgroupedtoggle.o -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lmysqlclient -lcrypt -lnsl -lm -lz -lglib-2.0
> 
> 
> I don't know what's up, and to tell you the truth, I don't really care a
> whole lot.  I'm not going to any static linking anyway.  It's this other
> guy who wants it, and he's not talking.  I'll let him take over this
> thread if he wants.
> 
> But...  if you want me to try something to see if you can get static
> linking working on my system, let me know.  I'm willing to give anything
> a shot.  I am curious about it.

I tried on one of my projects, and the only static libraries are those
compiled inside the project.
It seems that those flags are intended for libraries production. To have
static linking of the libraries in the executable, you must probably
list the libraires in the LDFLAGS, i.e. /usr/lib/libglib.a instead of
-lglib, which will need some editing in Makefile.am.




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