Ffmpeg : dylib : could not find libavformat => absolute paths in dylib (OSX)

Hello everyone,

I did a brew install ffmpeg to satisfy dependencies on a project I’m working on. Everything was ok until I try the dmg on a mac that has not Homebrew (and ffmpeg) installed.

Error : dylib : could not find library
Reason : image not found

When I do otool -L /usr/local/Cellar/ffmpeg/libavformat.58.dylib

libavformat.58.dylib:
/usr/local/opt/ffmpeg/lib/libavformat.58.dylib (compatibility version 58.0.0, current version 58.20.100)

/usr/local/Cellar/ffmpeg/4.1.4_2/lib/libavcodec.58.dylib (compatibility version 58.0.0, current version 58.35.100)
/usr/local/Cellar/ffmpeg/4.1.4_2/lib/libswresample.3.dylib (compatibility version 3.0.0, current version 3.3.100)
/usr/local/Cellar/ffmpeg/4.1.4_2/lib/libavutil.56.dylib (compatibility version 56.0.0, current version 56.22.100)

//after these three lines everything seems ok

/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
/usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
/usr/local/opt/libbluray/lib/libbluray.2.dylib (compatibility version 4.0.0, current version 4.2.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/local/opt/gnutls/lib/libgnutls.30.dylib (compatibility version 56.0.0, current version 56.0.0)
/usr/local/opt/rtmpdump/lib/librtmp.1.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/local/opt/xz/lib/liblzma.5.dylib (compatibility version 8.0.0, current version 8.4.0)
/usr/local/opt/opencore-amr/lib/libopencore-amrwb.0.dylib (compatibility version 1.0.0, current version 1.3.0)
/usr/local/opt/snappy/lib/libsnappy.1.dylib (compatibility version 1.0.0, current version 1.1.7)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 492.0.0)
/usr/local/opt/lame/lib/libmp3lame.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/opencore-amr/lib/libopencore-amrnb.0.dylib (compatibility version 1.0.0, current version 1.3.0)
/usr/local/opt/openjpeg/lib/libopenjp2.7.dylib (compatibility version 7.0.0, current version 2.3.1)
/usr/local/opt/opus/lib/libopus.0.dylib (compatibility version 9.0.0, current version 9.0.0)
/usr/local/opt/speex/lib/libspeex.1.dylib (compatibility version 7.0.0, current version 7.1.0)
/usr/local/opt/theora/lib/libtheoraenc.1.dylib (compatibility version 3.0.0, current version 3.2.0)
/usr/local/opt/theora/lib/libtheoradec.1.dylib (compatibility version 3.0.0, current version 3.4.0)
/usr/local/opt/libogg/lib/libogg.0.dylib (compatibility version 9.0.0, current version 9.3.0)
/usr/local/opt/libvorbis/lib/libvorbis.0.dylib (compatibility version 5.0.0, current version 5.8.0)
/usr/local/opt/libvorbis/lib/libvorbisenc.2.dylib (compatibility version 3.0.0, current version 3.11.0)
/usr/local/opt/x264/lib/libx264.155.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/opt/x265/lib/libx265.176.dylib (compatibility version 176.0.0, current version 176.0.0)
/System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1560.12.0)
/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 934.0.0)
/usr/local/opt/libsoxr/lib/libsoxr.0.dylib (compatibility version 0.0.0, current version 0.1.2)

I suspect the 3 lines referencing “/usr/local/Cellar” to be unexpected.

Could anyone with the same config (an iMac (originally based on 10.12 that I upgraded to OSX 10.13.6, I formatted my disk to reinstall a fresh 10.13.6 with no changes)) tell me if it has the same 3 lines ?

I tried to relink ffmpeg, nothing changed.

I am using xcode 10.1, and maybe the error is coming with it (strangely, in xCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ => MacOSX10.14.sdk is referenced instead of 10.13)

How can I obtain a correct install of ffmpeg ?

Could it be related to the way I link ffmpeg in my project (LIBS += -L/usr/local/opt/ffmpeg/lib INCLUDEPATH += /usr/local/opt/ffmpeg/include and where I need them -lavformat -lavcodec ...) ?

If it can help, in my built app, an otool -L libavformat.58.dylib shows these 3 links in absolute path, where others have been translated to @executable_path/../Frameworks/...

Thanks in advance for your help