我在使用 macdeployqt 为 Mac OS X 打包 Qt 应用程序时遇到问题。
在我的 Mac 上,我在 ~/Qt5.1.0/5.1.0/clang_64 上安装了 Qt5(这是 bin/ 和 lib/ 文件夹所在的位置)
我在 ~/Documents/QtProjects/renamer/ 上有一个名为“renamer”的 Qt 应用程序。
使用 Qt Creator,我在 ~/Documents/QtProjects/build-renamer-Desktop_Qt_5_1_0_clang_64bit-Release 上构建了我的应用程序的发布版本。所以我做的第一件事是otool
在我的应用程序上运行:
$ cd ~/Documents/QtProjects/build-renamer-Desktop_Qt_5_1_0_clang_64bit-Release
$ otool -L renamer.app/Contents/MacOS/renamer
renamer.app/Contents/MacOS/renamer:
/Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.0)
/Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.0)
/Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.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/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
我使用以下方法手动更正了损坏的路径install_name_tool
:
$ cd ~/Documents/QtProjects/build-renamer-Desktop_Qt_5_1_0_clang_64bit-Release
$ install_name_tool -change /Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets /Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets renamer.app/Contents/MacOS/renamer
$ install_name_tool -change /Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui /Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui renamer.app/Contents/MacOS/renamer
$ install_name_tool -change /Users/paul/Qt5.1.0//5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore /Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore renamer.app/Contents/MacOS/renamer
$ otool -L renamer.app/Contents/MacOS/renamer
renamer.app/Contents/MacOS/renamer:
/Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.0)
/Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.0)
/Users/paul/Qt5.1.0/5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.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/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
我已将 /bin 添加到我的 PATH 中,然后macdeployqt
从我的项目目录中调用。
$ cd ~/Documents/QtProjects/build-renamer-Desktop_Qt_5_1_0_clang_64bit-Release
$ sudo macdeployqt renamer.app
$ otool -L renamer.app/Contents/MacOS/renamer
renamer.app/Contents/MacOS/renamer:
@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.0)
@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.0)
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.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/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
但是,当我重命名/删除已安装的 Qt 库并运行应用程序时,我收到一条错误消息,指出在我的应用程序包中找不到 Qt 库。有什么建议么?