Re: static linking of gtk+ 2.4.1 and programs



Jean Br�rt wrote:
Le ven 11/06/2004 �6:39, Mirco Mueller a �it :

Hello there everybody!

	After reading the web and one straight day/night of trying out stuff, I
cannot figure out why static linking doesn't work. According to the
DirectFB-project this seem to be possible
(http://www.directfb.org/documentation/GTK_Embedded/).

I got those libs:

	atk-1.6.0
	fontconfig-2.2.2
	freetype-2.1.8
	glib-2.4.0
	gtk+-2.4.1
	jpeg-6b
	libpng-1.2.5
	pango-1.4.0
	tiff-v3.6.1
	zlib-1.2.1

	All (if possible) where compiled with --enable-static. After "make
install" I really have all those *.a files in <prefix>/lib

	Now trying to compile test-static.c (see bottom of eMail) with the
command...

gcc `pkg-config --cflags gtk+-2.0` -L/home/mirco/test-system/lib
-lgtk-x11-2.0 test-static.c -o test-static

... works as expected. The resulting binary test-static compiles and
runs.

	If I try the same with static linking like...

gcc `pkg-config --cflags gtk+-2.0` -static -L/home/mirco/test-system/lib
-Wl,-Bstatic -lgtk-x11-2.0 test-static.c -o test-static

... I get these errors:
>>
>>/tmp/ccuoq9YZ.o(.text+0xe): In function `delete_event':
>>: undefined reference to `g_print'

You need to statically link many other libs. See my posts around:
http://mail.gnome.org/archives/gtk-app-devel-list/2003-October/msg00002.html

I did a mixture of static and dynamic libs with:

gcc -o shapegen main.o gui.o xmalloc.o object.o menu.o dialog.o
    -Wl,-Bstatic,
    -lgtk-x11-2.0,-lgdk-x11-2.0,-latk-1.0,-lgdk_pixbuf-2.0,-ltiff,-lpng,
    -lpangoxft-1.0,-lpangox-1.0,-lpango-1.0,-lgmodule-2.0,-lgobject-2.0,
    -lglib-2.0,
    -Bdynamic,-lfreetype,-lfontconfig,-ljpeg,-ldl,
    -L/usr/X11R6/lib,-lXinerama,-lXi,-lXft,-lm,-lc

Whenever you get an undefined reference, run a small script using nm
to find which system lib has the symbol, then include it in your next
link.



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