Ffmpeg Mamp "Dyld: Library Not Loaded" Error

ffmpeg MAMP dyld: Library not loaded error

The problem is that the DYLD_LIBRARY_PATH is set in MAMP and I've installed ffmpeg via macports.

This might not be the best fix but it has me up and running for now:

In the /Applications/MAMP/Library/bin/envvars file and comment the following lines as below:

#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH

and restart Apache

dyld: Library not loaded ... Reason: Image not found

Find all the boost libraries (where exefile is the name of your executable):

$ otool -L exefile
exefile:
@executable_path/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

and for each libboost_xxx.dylib, do:

$ install_name_tool -change @executable_path/libboost_something.dylib /opt/local/lib/libboost_something.dylib exefile

and finally verify using otool again:

$ otool -L exefile
exefile:
/opt/local/lib/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

Manpages: otool install_name_tool

EDIT A while back I wrote a python script (copy_dylibs.py) to work out all this stuff automatically when building an app. It will package up all libraries from /usr/local or /opt/local into the app bundle and fix references to those libraries to use @rpath. This means you can easily install third-party library using Homebrew and package them just as easily.

I have now made this script public on github.

Xamarin Mac FFmpeg launch path not accessible

If you are not tied to NSTask you could use CliWrapper instead.

public static async ValueTask FfmpegRemoveAudio(string ffmpegPath, string inputFilePath, string outputFilePath)
{
await Cli.Wrap(ffmpegPath).WithArguments(new[] { "-i", inputFilePath, "-c", "copy", "-an", outputFilePath }).ExecuteAsync();
}

Beside of CliWrapper I also tested FfmpegCore and FFmpget.NET that also threw some similar exceptions like you describe. I have no glue, why they behavior different. See the complete working POC for details.

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

Update: As of December 2020 and beyond, brew switch does not work, so use the other answer by @angabriel:

brew install rbenv/tap/openssl@1.0
ln -sfn /usr/local/Cellar/openssl@1.0/1.0.2t /usr/local/opt/openssl

Original Answer:
Switch to an older openssl package

brew switch openssl 1.0.2s

Or, depending on your exact system configuration, you may need to switch to a different version. Check the output of ls -al /usr/local/Cellar/openssl for the version number to switch to.

brew switch openssl 1.0.2q
# or
brew switch openssl 1.0.2r
# or
brew switch openssl 1.0.2s
# or
brew switch openssl 1.0.2t
# etc...

command works fine through terminal but not shell_exec php

I think problem is in LD_LIBRARY_PATH and/or with library paths in general.

Go to shell and type

echo $LD_LIBRARY_PATH

and

ldd /usr/bin/wav2png

Do exact same from php script (be sure to grab output from these commands) and compare, I'm pretty sure you find the answer.

ImagickException with message Postscript delegate failed on MAMP 3.0.5

This might help. I just ran into the same issue and solved it a few hours later.

My first instinct was to make sure PHP was looking at the right PATH. For me, it was this:

putenv('PATH=' . getenv('PATH') . ':/usr/local/bin');

That didn't seem to help on its own, but I left the code in there because at some point GhostScript is going to need to know where to find those libpng files.

My next step was to examine MAMP's Apache error log. I found this as the probable culprit:

dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/bin/gs
Reason: Incompatible library version: gs requires version 29.0.0 or later, but libpng16.16.dylib provides version 23.0.0

Very strange, because my libpng in /usr/local/lib is up to date (1.6.12).

After much trial and error, I found that as of 3.0.5, MAMP is overriding with its own libpng files, in /Applications/MAMP/Library/lib

I removed libpng16.16.dylib from /Applications/MAMP/Library/lib, restarted MAMP, tried again, and got this error:

dyld: Library not loaded: /usr/local/lib/libfreetype.6.dylib
Referenced from: /usr/local/bin/gs
Reason: Incompatible library version: gs requires version 18.0.0 or later, but libfreetype.6.dylib provides version 17.0.0

Well that's something different, so I removed libfreetype.6.dylib from /Applications/MAMP/Library/lib as well, and restarted MAMP.

At this point, everything began working. At least for me, the two steps were to make sure PHP's PATH is looking at the right directory, and then to remove the offending files from MAMP's included libpng library, forcing PHP to use the up-to-date libpng files in /usr/local/lib.



Related Topics



Leave a reply



Submit