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

后端 未结 11 960
攒了一身酷
攒了一身酷 2020-11-28 05:01

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
         


        
相关标签:
11条回答
  • 2020-11-28 05:15

    I had this error that wasn't solved by brew update && brew upgrade. For some reason I needed to install it from scratch:

    $ brew install libpng

    0 讨论(0)
  • 2020-11-28 05:18

    I know this question has already an answer that gives a solution. But I want to give you my two cents to help people to understand the problem. Getting same issue I've created a specific question. I got same problem, but only with PHPStorm. And exactly when I try to run test from the editor.

    dyld is the dynamic linker

    I sow that dyld was looking for /usr/local/lib/libpng15.15.dylib but inside my /usr/local/lib/ there was not. In that folder, I got libpng16.16.dylib.

    Thanks to a comment, I undestand that my /usr/bin/php was a pointer to php 5.5.8. Instead, ... /usr/local/bin/php was 5.5.14. PHPStorm worked with /usr/bin/php that is default configuration. When I run php via console, I run /urs/local/bin/php.

    So, ... If you get some dyld error, maybe you have some wrong php configuration. That's the reason because

    $ brew update && brew upgrade
    $ brew reinstall php55
    

    But I dont know why this do not solve the problem to me. Maybe because I have

    0 讨论(0)
  • 2020-11-28 05:19

    I also had this problem, and none of the solutions in this thread worked for me. As it turns out, the problem was that I had this line in ~/.bash_profile:

    alias php="/usr/local/php/bin/php"
    

    And, as it turns out, /usr/local/php was just a symlink to /usr/local/Cellar/php54/5.4.24/. So when I invoked php -i I was still invoking php54. I just deleted this line from my bash profile, and then php worked.

    For some reason, even though php55 was now running, the php.ini file from php54 was still loaded, and I received this warning every time I invoked php:

    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php54/5.4.38/lib/php/extensions/no-debug-non-zts-20100525/memcached.so' - dlopen(/usr/local/Cellar/php54/5.4.38/lib/php/extensions/no-debug-non-zts-20100525/memcached.so, 9): image not found in Unknown on line 0
    

    To fix this, I just added the following line to my bash profile:

    export PHPRC=/usr/local/etc/php/5.5/php.ini
    

    And then everything worked as normal!

    0 讨论(0)
  • 2020-11-28 05:21

    I solved this by copying it over to the missing directory:

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

    brew reinstall libpng kept installing libpng16, not libpng15 so I was forced to do the above.

    0 讨论(0)
  • 2020-11-28 05:22

    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

    0 讨论(0)
  • 2020-11-28 05:25

    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.

    0 讨论(0)
提交回复
热议问题