3

I'm trying to build a large application, yet for some reason linking fails and ld responds

/usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/libX11.so

Steps I've tried:

  1. libx11-dev is correctly installed and the file libX11.so is a symlink that points to libX11.so.6.3.0
  2. Removed the link and recreated it with ln -s /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0 /usr/lib/x86_64-linux-gnu/libX11.so
  3. ldconfig -v to update the cache. No luck...

Anybody have any idea?

UPDATE

Sato Katsura posted a very helpful comment, suggesting I use -L/usr/lib/x86_64-linux-gnu -lX11 instead. This did work, and the application compiled without further issue!

Could anyone enlighten me as to what the difference is?

  • 3
    Try -L/usr/lib/x86_64-linux-gnu -lX11 instead of -l/usr/lib/x86_64-linux-gnu/libX11.so. – Satō Katsura Nov 17 '16 at 16:37
  • 1
    -labc (lower ell) searches, in possibly multiple directories depending your platform, for a file named libabc.x where x is either a for static or a platform-dependent suffix sometimes so for dynamic. You only specify abc; you don't specify the directory, or lib, or .so. – dave_thompson_085 Nov 17 '16 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.