Reputation: 81
I make a simple Qt app on mac with Qt 5.1. I deploy it by using macdeployqt but when I run it on other mac.
I run otool -L with my app and It says
/Users/aratn0n/Qt//5.1.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.0)
/Users/aratn0n/Qt//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.0)
/Users/aratn0n/Qt//5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
It seems it uses the library from my machine so when I run it on other machine it can't use the Qt library in the Frameworks folder within the app bundle.
How can I fix it?
Upvotes: 2
Views: 1728
Reputation: 3686
It's a bug in the installation of Qt that stops macdeployqt
running properly in 5.1.0 as mentioned in the answer by user kimbaudi.
It has been fixed in 5.1.1.
If for some reason you must use 5.1.0 then run macdeployqt
and you will find the Qt frameworks have been copied to the bundle.
You will then need to cd
to the Frameworks directory in the bundle and rewrite the link path via commands of the form
install_name_tool -change /Users/username/Source/Qt5//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui QtCore
You'll need to do it for every Qt framework to rewrite the dependencies on each other and also all the dylibs in the PlugIns directory as well as the executable.
Upvotes: 1
Reputation: 15585
I currently don't have a solution, but I ran into the same issue that you had when running macdeployqt
. Based on another post, the reason why macdeployqt
does not change the paths to local frameworks (@executable_path/../Frameworks/...) is because of the double slash in the paths of the Qt libraries. You need to manually run install_name_tool
to correct the double slashes
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 <EXECUTABLE>
Sorry I can't help anymore, but this is as far as I've got to deploying my app on Mac OS X. Unfortunately for me, when I remove/rename my installed Qt library, my app no longer works because it can't find the libraries set up by macdeployqt
.
Upvotes: 1
Reputation: 27621
It appears that macdeployqt hasn't done its job.
It should copy the required Qt libraries into the app bundle and set the paths for you.
Either look into why it's failing, or copy the files yourself and update the paths with install_name_tool
Upvotes: 1
Reputation: 14549
if you intend to use qt as a dynamic library then you will have to distribute the dylib... it is much simpler to use it as a static library. also you don't gain much from having a shared library if you aren't sharing it, so if you just have one process, build qt as a static lib and link it against your product, then there won't be a runtime dependency on an external lib.
Upvotes: 1