Fixing --as-needed problems - Example 2
sparky at pld-linux.org
sparky at pld-linux.org
Sun Aug 6 21:50:34 CEST 2006
Example 2.
Most common and just a little more difficult case,
evolution-data-server:
Compilation stops at this place:
=====================================================================
/bin/sh ../libtool --tag=CC --mode=link x86_64-pld-linux-gcc -ggdb -O2 -Wall -Wmissing-prototypes -Wno-sign-compare -Wl,--as-needed -o test-source-selector test-source-selector.o libedataserverui-1.2.la ../libedataserver/libedataserver-1.2.la -pthread -lglade-2.0 -lgtk-x11-2.0 -lxml2 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lcairo -lpangoft2-1.0 -lfontconfig -lfreetype -lz -lpango-1.0 -lX11 -lgnome-2 -lpopt -lbonobo-2 -lgnomevfs-2 -lbonobo-activation -lgconf-2 -lgobject-2.0 -lORBit-2 -lm -lgmodule-2.0 -ldl -lgthread-2.0 -lgnome-keyring -lglib-2.0 -lpthread
x86_64-pld-linux-gcc -ggdb -O2 -ftree-vectorize -ftree-vectorizer-verbose=1 -march=athlon64 -mmmx -msse -msse2 -m3dnow -mfpmath=sse -Wall -Wmissing-prototypes -Wno-sign-compare -Wl,--as-needed -o .libs/test-source-selector test-source-selector.o -pthread ./.libs/libedataserverui-1.2.so [many, many .so and -l libraries] -lpthread
./.libs/libedataserverui-1.2.so: undefined reference to `glade_xml_new'
./.libs/libedataserverui-1.2.so: undefined reference to `gnome_keyring_find_items_sync'
./.libs/libedataserverui-1.2.so: undefined reference to `gnome_keyring_get_default_keyring_sync'
./.libs/libedataserverui-1.2.so: undefined reference to `gnome_keyring_attribute_list_free'
./.libs/libedataserverui-1.2.so: undefined reference to `glade_xml_get_widget'
./.libs/libedataserverui-1.2.so: undefined reference to `gnome_keyring_create_sync'
./.libs/libedataserverui-1.2.so: undefined reference to `gnome_keyring_item_delete_sync'
./.libs/libedataserverui-1.2.so: undefined reference to `gnome_keyring_item_create_sync'
collect2: ld returned 1 exit status
make[2]: *** [test-source-selector] Error 1
=====================================================================
It's different case, now it isn't problem with binary file, but with
shared library. And the difficulty is it shows up at executable-linking
time, because undefined symbols in libraries are permited.
OK, lets try to fix that library:
$ grep gnome_keyring_item_delete_sync /usr/lib64/lib*.so
Binary file /usr/lib64/libgnome-keyring.so matches
$ grep glade_xml_new /usr/lib64/lib*.so
Binary file /usr/lib64/libglade-2.0.so matches
Editing Makefile we find:
GNOME_KEYRING_LIBS = -lgnome-keyring -lglib-2.0
So add this one and glade to that library deps:
libedataserverui_1_2_la_LIBADD = \
$(top_builddir)/addressbook/libebook/libebook-1.2.la \
$(GNOME_KEYRING_LIBS) -lglade-2.0 \
$(E_DATA_SERVER_LIBS)
As it uses libtool, remove .la to force regeneration:
$ rm libedataserverui-1.2.la
and try to build
$ make
passes without problems.
Now we only need to fix it correcly, after looking at configure.in and
Makefile.am one can see it was only a typo:
libedataserverui_1_2_la_LIBADD = \
$(top_builddir)/addressbook/libebook/libebook-1.2.la \
$(E_DATA_SERVER_UI_LIBS)
^^^
This time, why was it working without --as-needed ?
test-source-selector binary was linked with all libraries needed by
libedataserverui-1.2.so, and the binary was the one who provided
missing symbols to libedataserverui-1.2.so
Easy, wasn't it ?
--
____ Sparky{PI] -- Przemyslaw _ ___ _ _ ........... LANG...Pl..Ca..Es..En
/____) ___ ___ _ _ || Iskra | | _ \| | | : WWW........ppcrcd.pld-linux.org
\____\| -_)'___| ||^'||//\\// < | _/| | | : JID......sparky<at>jabberes.org
(____/|| (_-_|_|| ||\\ || |_ |_| |_| _| : Mail....sparky<at>pld-linux.org
More information about the pld-devel-en
mailing list