Linux – ld cannot find an existing library


I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too.

I am calling the linker with:

g++ -w (..lots of .o files/include directories/etc..) \
-L/usr/lib -lmagic

ld complains:

/usr/bin/ld: cannot find -lmagic

However, libmagic exists:

$ locate
$ ls -all /usr/lib/*
lrwxrwxrwx 1 root root    17 2008-12-01 03:52 /usr/lib/ ->
-rwxrwxrwx 1 root root 84664 2008-09-09 00:05 /usr/lib/
$ ldd /usr/lib/ =>  (0xb7f85000) => /usr/lib/ (0xb7f51000) => /lib/i686/cmov/ (0xb7df6000)
    /lib/ (0xb7f86000)
$ sudo ldconfig -v | grep "libmagic" ->

How do I diagnose this problem further, and what could be wrong? Am I doing something completely stupid?

Best Answer

The problem is the linker is looking for but you only have

A quick hack is to symlink to