title: ld cannot find an existing library
body: <p>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.</p>
  
  <p>I am calling the linker with:</p>
  
  <pre><code>g++ -w (..lots of .o files/include directories/etc..) \
  -L/usr/lib -lmagic
  </code></pre>
  
  <p>ld complains:</p>
  
  <pre><code>/usr/bin/ld: cannot find -lmagic
  </code></pre>
  
  <p>However, libmagic exists:</p>
  
  <pre><code>$ locate libmagic.so
  /usr/lib/libmagic.so.1
  /usr/lib/libmagic.so.1.0.0
  $ ls -all /usr/lib/libmagic.so.1*
  lrwxrwxrwx 1 root root    17 2008-12-01 03:52 /usr/lib/libmagic.so.1 -&gt; libmagic.so.1.0.0
  -rwxrwxrwx 1 root root 84664 2008-09-09 00:05 /usr/lib/libmagic.so.1.0.0
  $ ldd /usr/lib/libmagic.so.1.0.0 
      linux-gate.so.1 =&gt;  (0xb7f85000)
      libz.so.1 =&gt; /usr/lib/libz.so.1 (0xb7f51000)
      libc.so.6 =&gt; /lib/i686/cmov/libc.so.6 (0xb7df6000)
      /lib/ld-linux.so.2 (0xb7f86000)
  $ sudo ldconfig -v | grep "libmagic"
      libmagic.so.1 -&gt; libmagic.so.1.0.0
  </code></pre>
  
  <p>How do I diagnose this problem further, and what could be wrong? Am I doing something completely stupid?</p>