Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

macos - Qt 5.1 and Mac: Bug making macdeployqt not working properly

I have a problem since the version 5.1rc2 of Qt for Mac OS X. (5.1 is also affected, not the 5.1rc1)
When I build my app and do a otool -L on the binary file to see the paths of the shared libraries, I get: (it's just a sample, I removed some of them for clarity)

/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 
    (compatibility version 45.0.0, current version 1187.37.0)
/Users/chris/**Qt5.1.0//5.1.0**/clang_64/lib/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtQml.framework/Versions/5/QtQml
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui
    (compatibility version 5.1.0, current version 5.1.0)

As you can see there is a double slash in the paths of the Qt libraries. When I use macdeployqt to deploy my app, those paths aren't changed to local frameworks (@executable_path/../Frameworks/...), because of this... I have to do it manually with the install_name_tool, and it's really annoying.

What can I do to fix this? (I've tried re-installing Qt, cleaning, runing qmake again and rebuilding without change)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

having the same issue. I applied next workaround:

after I build my program, I've changed links inside exe to a right ones

install_name_tool -change /Users/username/Qt5.1.0//5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick  /Users/username/Qt5.1.0/5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick <YourExecutable>

After this workaround macdeployqt has changed all links inside exe to a relative ones.

But my App became broken. The thing is that I've added all my images and QML files into resources. After I ran macdeployqt - I can not run my app. When I ran this with gdb - I see next error:

QQmlApplicationEngine failed to load component 
qrc:/qml/main.qml:-1 File not found

Error: Your root item has to be a Window.

So somehow all my resources became unavailable. Does anyone know how to fix that?

I also started a discussion on qt forum

UPDATE, HOW TO DEPLOY:

  1. Use this script to get rid of double slashes inside dynamic linking paths.

    ./fixqt.sh ~/Qt5.1.0/5.1.0/clang_64

  2. Build macdeployqt tool from this repository.

  3. Run macdeployqt and specify dir with your qml source:

    macdeployqt MyApp.app/ -qmldir=../src/qml -dmg

After those steps I managed to run my application on different OS X system, without QT Installed. I've added all my qml files and images into resources. QtQuick and QtQuick.2 modules copied inside MyApp.app/Content/MacOS/

Hope it helps


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...