使用opencv和ffmpeg dylib错误部署QT项目

Deploying QT project with opencv and ffmpeg dylib error

当我使用 opencv 和 ffmpeg dylib 构建我的项目时,我的应用程序因错误而崩溃:

Dyld Error Message: Library not loaded: /usr/local/Cellar/ffmpeg/4.1.3/lib/libswresample.3.dylib

Referenced from: /Applications/myApp.app/Contents/Frameworks/libavcodec.58.dylib Reason: image not found

我已经尝试使用 install_name_tool 尝试使用此更改路径:

install_name_tool -change libavcodec.58.dylib 

@executable_path/../Frameworks/libavcodec.58.dylib

/Users/me/code/build_output/MyAppQML/myApp.app/Contents/MacOS/myApp

虽然这修改了文件,但我仍然遇到相同的错误并在 运行 时崩溃。

install_name_tool 适合解决这个问题还是我应该看看其他东西?

我在 libavcodec 上使用了 otool。58.dylib 这表明一些路径链接到 @executable_path

@executable_path/../Frameworks/libavcodec.58.dylib (compatibility version 58.0.0, current version 58.35.100)
    /usr/local/Cellar/ffmpeg/4.1.3/lib/libswresample.3.dylib (compatibility version 3.0.0, current version 3.3.100)
    /usr/local/Cellar/ffmpeg/4.1.3/lib/libavutil.56.dylib (compatibility version 56.0.0, current version 56.22.100)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    @executable_path/../Frameworks/liblzma.5.dylib (compatibility version 8.0.0, current version 8.4.0)
    @executable_path/../Frameworks/libopencore-amrwb.0.dylib (compatibility version 1.0.0, current version 1.3.0)

已通过使用修复:

install_name_tool -change /usr/local/Cellar/ffmpeg/4.1.3/lib/libswresample.3.dylib 

@executable_path/../Frameworks/libswresample.3.dylib

/Users/me/code/build_output/MyAppQML/myApp.app/Contents/Frameworks/libavcodec.58.dylib

感谢@L指点。斯科特·约翰逊