Results 1 to 3 of 3
I have been debugging (successfully!) a little docked applet in Debian. This involved repeated compilations using the command gcc `pkg-config gtk+-2.0 --cflags --libs` -o trashcan trashcan.c. While I was working ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-26-2011 #1
[SOLVED] Question about library linking
While I was working on this, Debian Testing went over from Squeeze to Wheezy. Suddenly the program wouldn't build. I got the message:
/usr/bin/ld: /usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/libgdk-x11-2.0.so: undefined reference to symbol 'XSetWMHints'
/usr/bin/ld: note: 'XSetWMHints' is defined in DSO /usr/lib/libX11.so.6 so try adding it to the linker command line.
I was surprised because:
a) I never had this error before when building this program.
b) I have never before seen any linking error that actually told you where to find the missing function!
So I added -lX11 and that solved the immediate problem. But I never had to link explicitly to libX11 before; it just came with gtk. What has changed?
Both gcc and gtk2 are new in Wheezy but not very new, only Debian version changes. And in Crux 2.7 (which has significantly later versions of both packages), I can still build the same program without specifying libX11.
Could someone explain why this kind of explicit linking to a library that is linked in anyway through another library is sometimes necessary, sometimes not?
- 02-26-2011 #2
- Join Date
- Apr 2010
- Novosibirsk, Russia
It's because a new DSO mechanism was applied to GCC - it happened not so far. It tells that implied linking was declined and developer must explicitly link all application libraries by himself.
Features/ChangeInImplicitDSOLinking - FedoraProject
- 02-26-2011 #3
Brilliant! That exactly explains it. Obviously the Debian team made the same modification. The reason it doesn't happen in Crux is probably because Crux uses vanilla packages as far as possible.