dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib with anything php related

user3458861 picture user3458861 · Mar 25, 2014 · Viewed 112.5k times · Source

Using any php application results in:

dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
[1]    4494 trace trap  php

Most of my php applications were installed using homebrew with the exception of composer (installed using curl)

I tried removing the the libpng and reinstalling with homebrew to no avail.

Next was to switch to latest version of libpng 1.5 as stated in the error message:

$ brew info libpng
libpng: stable 1.6.10 (bottled) 
http://www.libpng.org/pub/png/libpng.html
/usr/local/Cellar/libpng/1.5.17 (15 files, 1.0M)
Poured from bottle
/usr/local/Cellar/libpng/1.5.18 (15 files, 1.0M)
Poured from bottle
/usr/local/Cellar/libpng/1.6.10 (17 files, 1.3M) *

$ brew switch libpng 1.5.18
Cleaning /usr/local/Cellar/libpng/1.5.17
Cleaning /usr/local/Cellar/libpng/1.5.18
Cleaning /usr/local/Cellar/libpng/1.6.10
16 links created for /usr/local/Cellar/libpng/1.5.18

Now the error has changed to:

dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/lib/libfreetype.6.dylib
Reason: image not found
[1]    6993 trace trap  phpunit

Im running Mavericks (10.9.2) and PHP 5.5.1.

Thanks in advance!

Answer

Pera Jovic picture Pera Jovic · Mar 25, 2014

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.