title: Why do I fail to load the dylib?
body: <p>Here is the command I typed:</p>
  
  <pre><code>clang++ -Iboost -Ijpeg_lib/include/ -Ljpeg_lib/lib/ -ljpeg.9 mandelbrot.cpp
  </code></pre>
  
  <p>The directory structure is like this:</p>
  
  <pre><code>mandelbrot.cpp
  /boost
  /jpeg_lib/lib/
      libjpeg.9.dylib
  /jpeg_lib/include/
  </code></pre>
  
  <p>The compilation is successful, but when I run the binary file, an error occurs:</p>
  
  <blockquote>
    <p>dyld: Library not loaded: /usr/local/lib/libjpeg.9.dylib</p>
    
    <p>Referenced from: /Users/hanxu/Documents/./a.out</p>
    
    <p>Reason: image not found</p>
    
    <p>Trace/BPT trap: 5</p>
  </blockquote>
  
  <p>I have specified the library searching path to jpeg_lib/include/, why does the program still search at /usr/local/lib ?</p>