title: dyld: Library not loaded: /usr/local/lib/libpng.3.dylib when using php
body: <p>I am getting an error when running <code>php</code>:</p>
  
  <pre><code>$ php -v
  dyld: Library not loaded: /usr/local/lib/libpng.3.dylib
    Referenced from: /usr/local/bin/php
    Reason: image not found
  Trace/BPT trap: 5
  </code></pre>
  
  <p>I read this <a href="https://stackoverflow.com/questions/22631026/dyld-library-not-loaded-usr-local-lib-libpng16-16-dylib-with-anything-php-rel">dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib with anything php related</a> but I'm not sure if PHP was installed with brew as this command <code>brew reinstall php55</code> (or anything else like <code>brew reinstall php</code>, <code>brew reinstall php56</code>) does not work.</p>
  
  <p>The next answer suggests symlinking this missing library. e.g.</p>
  
  <pre><code>$ locate libpng.3.dylib
  /opt/X11/lib/libpng.3.dylib
  /usr/local/php5/lib/libpng.3.dylib
  $ ls -l /usr/local/php5/lib/libpng.3.dylib
  lrwxrwxrwx  1 snowcrash  admin  18 15 Jan  2008 /usr/local/php5/lib/libpng.3.dylib -&gt; libpng.3.0.0.dylib
  $ ls -l /usr/local/php5/lib/libpng.3.0.0.dylib 
  -rwxrwxrwx  1 snowcrash  admin  422632  4 May  2007 /usr/local/php5/lib/libpng.3.0.0.dylib
  $ ln -s /usr/local/php5/lib/libpng.3.0.0.dylib  /usr/local/lib/libpng.3.dylib
  $ php -v
  dyld: Library not loaded: /usr/local/lib/libpng.3.dylib
  Referenced from: /usr/local/bin/php
  Reason: Incompatible library version: php requires version 20.0.0 or later, but libpng.3.dylib provides version 4.0.0
  Trace/BPT trap: 5
  </code></pre>
  
  <p>but it seems the version is too old so not sure what to do. I assume I need to upgrade PHP somehow or find a more up to date version of libpng.</p>
  
  <p>Any suggestions?</p>