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)
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:
Use this script to get rid of double slashes inside dynamic linking paths.
./fixqt.sh ~/Qt5.1.0/5.1.0/clang_64
Build macdeployqt tool from this repository.
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
I'm posting this as a solution as I just lost (another) day to this process with 5.3 (and I assume it is the same for 5.4).
macdeployqt
now works as intended but the failed piece of documentation here is that you need to specify and absolute path to each qml directory (relative might work but I've had no luck at all).
Here's how I solved that for my release process:
In the project file I now have
mac {
CONFIG += x86
CONFIG += c++11
#Disable these for development
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 #I'm not sure I need this
QMAKE_POST_LINK = {path to macdeployqt}/macdeployqt {appname}.app -qmldir=$$PWD/qml/{appname}/ -verbose=3
}
This effectively calls:
macdeployqt appname.app - /path/to/source/code/appname/qml/appname/ -verbose=3
When the absolute path is specified it appears to work fine but when I use a relative path I run into several problems. PWD
is the source directory and the executables are run from the build directory. The absolute path of the build is OUT_PWD
.
The beauty of keeping this in the release configuration in the project is that I debug normally (no app package) and the release package correctly builds from creator. Theoretically I can just wrap that into a Jenkins build and be done with this headache once and for all.
The Short Answer
macdeployqt
MUST SCAN your qml files if you're using them otherwise the imports will be broken and you'll see errors like:
QQmlApplicationEngine failed to load component
qrc:/qml/LightAssistant.qml:5 module "QtQuick.Dialogs" is not installed
qrc:/qml/LightAssistant.qml:3 module "QtQuick.Window" is not installed
qrc:/qml/LightAssistant.qml:4 module "QtQuick.Controls" is not installed
qrc:/qml/LightAssistant.qml:1 module "QtQuick" is not installed
qrc:/qml/LightAssistant.qml:2 module "QtQuick.Layouts" is not installed
Finally, my directory structure looks like this:
Project
- qml
- appname
files1.qml
files2.qml
...
filesX.qml
- js
- images
These then get packaged into the Resource file which, by definition, are not copied to the build directory and thus macdeployqt can't scan them unless the pathing is perfect. By using this build process I have a step in my build (release) that just deals with it and I don't have to run macdeployqt
when I'm debugging. Keep in mind if you use the app_bundle you need to run macdeployqt on each build which will really mess with your debugging workflow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With