dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib with anything php related
I suggest you run:
$ brew update && brew upgrade
Until couple of minutes ago I had this problem, too. Because I have an up to date PHP version, I solved it with:
$ brew reinstall php55
Hope that helps.
I followed the above (never a bad idea to keep up to date with brew anyhow) and still had the same exact issue:
LAPTOP:folder Username$ php -v
dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Trace/BPT trap: 5
Then figured out a simpler way:
Search for your libpng version(s) on your box:
# Requires locate & updatedb for mac os x
# See Link [1]
LAPTOP:folder Username$ locate libpng15.15.dylib
/Applications/GIMP.app/Contents/Resources/lib/libpng15.15.dylib
/usr/X11/lib/libpng15.15.dylib
/usr/local/Cellar/libpng/1.5.14/lib/libpng15.15.dylib
Make a symlink:
LAPTOP:folder Username$ ln -s /usr/local/Cellar/libpng/1.5.14/lib/libpng15.15.dylib /usr/local/lib/libpng15.15.dylib
Try again:
LAPTOP:folder Username$ php -v
PHP 5.3.26 (cli) (built: Aug 25 2013 16:07:23)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
1) Mac OS X equivalent of locate
It's because there's no symlinks for libpng. You need to link libpng again.
brew unlink libpng && brew link libpng
And you may get some error. I fixed that error by correcting permission. Maybe it's because of uninstalled macports.
sudo chown -R yourid:staff /usr/local/share/man/
Create link again and it'll work.