macdeployqt 似乎无法正常工作

macdeployqt seems not work correctly

我目前正在尝试在 MacO 上部署我的 Qt5.8 应用程序。 Travis 的最新工作是 here。我在使用 macdeployqt 后得到了 VNote.dmg 文件。然后我将它复制到另一个 MacOS 并尝试 运行 它,但出现以下错误:

/Applications/VNote/VNote.app/Contents/MacOS/VNote ; exit;
dyld: Library not loaded: /usr/local/Cellar/qt5/5.8.0_1/lib/QtWebEngineCore.framework/Versions/5/QtWebEngineCore
  Referenced from: /Applications/VNote/VNote.app/Contents/Frameworks/QtWebEngineWidgets.framework/Versions/5/QtWebEngineWidgets
  Reason: image not found
Trace/BPT trap: 5
logout

然后我用otool -L /Applications/VNote.app/Contents/MacOS/VNote得到输出:

/Applications/VNote.app/Contents/MacOS/VNote:
    @executable_path/../Frameworks/QtWebEngineWidgets.framework/Versions/5/QtWebEngineWidgets (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtWebEngineCore.framework/Versions/5/QtWebEngineCore (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.8.0, current version 5.8.0)
    /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    @executable_path/../Frameworks/QtQml.framework/Versions/5/QtQml (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtWebChannel.framework/Versions/5/QtWebChannel (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtPositioning.framework/Versions/5/QtPositioning (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport (compatibility version 5.8.0, current version 5.8.0)
    @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.8.0, current version 5.8.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

然后otool -L /Applications/VNote.app/Contents/Frameworks/QtWebEngineWidgets.framework/Versions/5/QtWebEngineWidgets显示:

/Applications/VNote.app/Contents/Frameworks/QtWebEngineWidgets.framework/Versions/5/QtWebEngineWidgets:
    @executable_path/../Frameworks/QtWebEngineWidgets.framework/Versions/5/QtWebEngineWidgets (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtWebEngineCore.framework/Versions/5/QtWebEngineCore (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.8.0, current version 5.8.0)
    /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtQml.framework/Versions/5/QtQml (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtWebChannel.framework/Versions/5/QtWebChannel (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtPositioning.framework/Versions/5/QtPositioning (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.8.0, current version 5.8.0)
    /usr/local/Cellar/qt5/5.8.0_1/lib/QtQuickWidgets.framework/Versions/5/QtQuickWidgets (compatibility version 5.8.0, current version 5.8.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

QtWebEngineWidgets 似乎仍然引用 Travis 环境中的绝对路径。

我应该如何部署 Qt 应用程序?非常感谢!

我认为这是 macdeployqt 的错误。它似乎没有修复所有框架的依赖性。相反,它只是修复了可执行文件的直接依赖关系。

感谢 macdeployqtfix,这是一个可以完成所有事情的工具 macdeployqt 忘记了。

顺便说一下,如果您的应用使用 QWebEngineWidget,您还需要 macdeployqt 帮助程序 QWebEngineProcess 捆绑包。