Hi Matthias, thanks for your patience. First of all, I just noticed a mistake in my simple example linkage of libfoo - I forgot to link libfoo with libm at creation time, which is crucial for this bug. The commands to use are
gcc -fPIC -c a.c gcc -shared -fPIC a.o -o libfoo.so -lm gcc -fPIC -c b.c gcc -shared -fPIC b.o -o libbar.so When I now type gcc c.c -L . -lbar -lfoo -lm -Wl,--trace-symbol=sinh I get ./libbar.so: reference to sinh /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libm.so: definition of sinh ./libbar.so: undefined reference to `sinh' collect2: ld gab 1 als Ende-Status zurück (in case you are not German-speaking: collect2: ld returned exit code 1) The same happens if I change the order into -lfoo -lbar -lm What works, however, is to leave out -lfoo gcc c.c -L . -lbar -lm -Wl,--trace-symbol=sinh Now, according to my understanding of the linker, the presence of superfluous -lfoo should not be able to break the link. Please correct me, if I am wrong. The point is that -lm gets very early into LIBS in the configure (which used to be very reasonable). If I use AC_CHECK_LIB (bar, ...) even with the extra-libs option), it will always test for -lbar $LIBS extralibs so I have no chance to squeeze the -lm between the tested -lbar and $(LIBS). And even if I would manage to, it is not sure whether libtool would not remove double -lm's when we do the real linking in the Makefile. When I said that this bug breaks AC_CHECK_LIBS, I meant exactly this: there is no easy way to check for multiple libs, without introducing non-standard dependencies on the libraries like "please test lbar only in the absence of lfoo, even if you may want to link them botht a later stage". Christoph -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/945927 Title: ld incorrectly gives 'undefined reference' To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/945927/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
