I use qmake to compile my Qt application project on my MacBook.
To do this, you need a dylib called libcore.dylib, and I put it in a directory $$OUT_PWD/../libs.
for compilation I add this code to the file.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
to run, I add
macx {
QMAKE_LFLAGS += -Wl,-rpath,$$OUT_PWD/../libs
}
for compilation libcore.dylib, I add
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
}
After that, I can run the created application directly.
But when I deploy the application with help macdeployqt, errors occur.
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")
QSet rpaths /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)
shared.cpp
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, msg .
Qt - 5.5.0, MaintenanceTool.
? macdeployqt? ?