我使用qmake在我的MacBook上编译我的Qt应用程序项目
它需要一个名为libcore.dylib
的dylib,我将它放入dir $$OUT_PWD/../libs
。
为了编译,我在.pro
文件
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libs/release
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libs/debug
else:unix: LIBS += -L$$OUT_PWD/../libs
LIBS += -lcore
要运行,我添加
macx {
QMAKE_LFLAGS += -Wl,-rpath,$$OUT_PWD/../libs
}
编译libcore.dylib
,我添加
win32:CONFIG(release, debug|release): DESTDIR = $$OUT_PWD/../libs/release
else:win32:CONFIG(debug, debug|release): DESTDIR = $$OUT_PWD/../libs/debug
else:unix: DESTDIR = $$OUT_PWD/../libs
macx {
QMAKE_SONAME_PREFIX = @rpath
}
完成此操作后,我可以直接运行生成的应用程序
但是当我使用macdeployqt
部署应用程序时,会发生错误。
ERROR: Cannot resolve rpath "QtGui.framework/Versions/5/QtGui (compatibility version 5.5.0, current version 5.5.0)"
ERROR: using QSet("/Users/sjchao/Documents/QtBuild/project/debug/app/../libs")
ERROR: Cannot resolve rpath "QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.0)"
ERROR: using QSet("/Users/sjchao/Documents/QtBuild/project/debug/app/../libs")
ERROR: Cannot resolve rpath "QtGui.framework/Versions/5/QtGui (compatibility version 5.5.0, current version 5.5.0)"
ERROR: using QSet("/Users/sjchao/Documents/QtBuild/project/debug/app/../libs")
ERROR: Cannot resolve rpath "QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.0)"
ERROR: using QSet("/Users/sjchao/Documents/QtBuild/project/debug/app/../libs")
ERROR: Cannot resolve rpath "QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.5.0, current version 5.5.0)"
ERROR: using QSet("/Users/sjchao/Documents/QtBuild/project/debug/app/../libs")
rpath的QSet不包含/Users/sjchao/Applications/Qt/5.5/clang_64/lib
!
但最终的编译cmd包含-Wl,-rpath,/Users/sjchao/Applications/Qt/5.5/clang_64/lib
!它是无用的?
那时我看到了一点macdeployqt
来源shared.cpp
我使用otool -l
查看LC_RPATH
Load command 27
cmd LC_RPATH
cmdsize 112
path /Users/sjchao/Documents/QtBuild/project/debug/app/../libs (offset 12)
Load command 28
cmd LC_RPATH
cmdsize 64
path /Users/sjchao/Applications/Qt/5.5/clang_64/lib (offset 12)
中的一些代码
426 while (i.hasNext()) {
427 if (i.next().contains("cmd LC_RPATH") && i.hasNext() &&
428 i.next().contains("cmdsize") && i.hasNext()) {
429 const QString &rpathCmd = i.next();
430 int pathStart = rpathCmd.indexOf("path ");
431 int pathEnd = rpathCmd.indexOf(" (");
432 if (pathStart >= 0 && pathEnd >= 0 && pathStart < pathEnd) {
433 QString rpath = rpathCmd.mid(pathStart + 5, pathEnd - pathStart - 5);
434 if (resolve) {
435 rpaths << resolveDyldPrefix(rpath, path, executablePath);
436 } else {
437 rpaths << rpath;
438 }
439 }
440 }
441 }
使用LC_RPATH
运行此代码,rpaths
应包含/Users/sjchao/Applications/Qt/5.5/clang_64/lib
,但错误消息说明没有。
我的Qt版本是5.5.0,我已使用MaintenanceTool将其更新为最新版本
我该怎么办?这是macdeployqt
的错误吗?有什么建议吗?