Find the answer to your Linux question:
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.
  1. #1
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,217

    [SOLVED] Question about library linking


    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 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?
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  2. #2
    Linux Newbie
    Join Date
    Apr 2010
    Location
    Novosibirsk, Russia
    Posts
    145
    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

  3. #3
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,217
    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.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •