Coder Perfect

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


When you use a php application, you get the following results:

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

With the exception of composer, I installed most of my php programs using homebrew (installed using curl)

I tried deleting libpng and reinstalling it with homebrew, but it didn’t work.

As stated in the error message, the next step was to upgrade to the most recent version of libpng 1.5:

$ brew info libpng
libpng: stable 1.6.10 (bottled)
/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

The error has now been 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

Mavericks (10.9.2) and PHP 5.5.1 are installed.

Thanks in advance!

Asked by user3458861

Solution #1

I recommend that you run:

$ brew update && brew upgrade

I, too, had similar problem until a few minutes ago. Because I have the most recent PHP version, I was able to address the problem by using:

$ brew reinstall php55

Hope that helps.

Answered by Pera Jovic

Solution #2

I did everything listed above (it’s never a bad idea to be current with brew anyhow) and still got the same problem:

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 I came up with a simpler solution:

On your box, look for your libpng version(s):

# Requires locate & updatedb for mac os x
# See Link [1] 
LAPTOP:folder Username$ locate 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) The Mac OS X equivalent of the find command

Answered by phpguru

Solution #3

It’s because libpng doesn’t have any symlinks. You’ll need to re-link libpng.

brew unlink libpng && brew link libpng

And there’s a chance you’ll get an error. By correcting permission, I was able to resolve the issue. Maybe it’s because macports isn’t installed.

sudo chown -R yourid:staff /usr/local/share/man/

Create link again and it’ll work.

Answered by Jonghee Park

Solution #4

I was able to resolve this by copying it to the missing directory:

cp /opt/X11/lib/libpng15.15.dylib /usr/local/lib/libpng15.15.dylib

brew install libpng libpng libpng libpng libpng libp I was compelled to do the above since I kept installing libpng16 instead of libpng15.

Answered by user391339

Solution #5

It was libjpeg in my instance. It was as simple as running brew reinstall libjpeg and everything was fine!

Answered by saada

Post is based on