Cannot run a binary executable from PHP and MAMP?

I recently encountered this obscure error when trying to run an external program using PHP (which was bundled with MAMP Pro) on Mac OS X:

dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
Expected in: /Applications/MAMP/Library/lib/libJPEG.dylib
in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib

Oddly, other commands execute fine from PHP using shell_exec(). Even more strangely, the external program ran fine when executed from a PHP command-line script, just not from MAMP’s bundled version of Apache!

Thanks to this tidbit from the PrinceXML forums, the solution was easy:

MAMP changes the environment variable $DYLD_LIBRARY_PATH. Check the file:

/Applications/MAMP/Library/bin/envvars

and try out if commenting out the two uncommented lines will work for you.

16 thoughts on “Cannot run a binary executable from PHP and MAMP?”

  1. I’m experiencing the same problem. Sadly, changing the envvars file does nothing for me, the same DYLD_LIBRARY_PATH is still set in MAMP (2.0.5) on startup.

  2. Hi. Can you post what the resulting envvars file should look like? I presume the two lines they refer to are the DYLD_LIBRARY_PATH assignment lines, but I just wanted to be sure.

    Thanks for the post!
    -Jibran

    Here’s my envvars file for reference:

    # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements. See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License. You may obtain a copy of the License at
    #
    # http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    #
    #
    # envvars-std - default environment variables for apachectl
    #
    # This file is generated from envvars-std.in
    #
    if test "x$DYLD_LIBRARY_PATH" != "x" ; then
    DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
    else
    DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib"
    fi
    export DYLD_LIBRARY_PATH
    #

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>