4

I use qmake to compile my Qt Application project on my MacBook.
It need a dylib called libcore.dylib, and I put it into dir $$OUT_PWD/../libs.

for compile, I add this code in .pro file

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

for running, I add

macx {
    QMAKE_LFLAGS += -Wl,-rpath,$$OUT_PWD/../libs
}

to compile 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 this done, I can run the generated app directly.
But when I deploy the app using 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")

The QSet of rpaths did not contain /Users/sjchao/Applications/Qt/5.5/clang_64/lib !
But the final compile cmd contains -Wl,-rpath,/Users/sjchao/Applications/Qt/5.5/clang_64/lib ! It's useless?
I saw a little macdeployqt source shared.cpp, then I use otool -l to see 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)

See some code in 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     }

Run this code with the LC_RPATH, rpaths should contains /Users/sjchao/Applications/Qt/5.5/clang_64/lib, but the error msg said no.
My Qt version is 5.5.0, and I have updated it to the lastest version using MaintenanceTool.
What should I do? Is it a bug of macdeployqt? Any suggestions?

sjchao
  • 41
  • 4

0 Answers0