Unsolved Qt Application bundle - Question about Framework
sandy_ind last edited by A Former User
I'm building Qt application on OS X and creating an app bundle. I was referring the link http://doc.qt.io/qt-5/osx-deployment.html and found it very useful.
My only question is :
In the example given on that link, the whole framework directory is being copied to the bundle.
cp -R /path/to/Qt/lib/QtCore.framework
My application depends on about 10 Frameworks like QtCore, QtGui, QtWebkit, etc.. and found that the app bundle size is huge (around 400MB). I was wondering if it is really needed to copy the complete framework directory (that contains Headers, and other extra directories) ? or just copying the dependent lib would be sufficient?
**cp /path/to/Qt/lib/QtGui.framework/Versions/4.0/QtGui plugandpaint.app/Contents/Frameworks/Versions/4.0/QtGui **
I found my application to be working even if I don't bundle the whole framework. But, just wanted to confirm as I may have not tested the features of the app that may require those extra files.
Please do help. Thanks!
You only need the items (library and frameworks) that the application actually uses. An app that is 400 mb sounds like everything was included even if not used (as you suggested).
Qt has a utility called 'macdeployqt' which does a good job of identifying what the application actually uses and putting all this in the app bundle. You didn't mention this utility so I am just putting this out there in case you didn't see it. You can build the app bundle manually if necessary (using otool etc.) but it isn't necessary.
For the frameworks you can't just include the library. A framework will contain headers and other 'required' items as well.
sandy_ind last edited by sandy_ind
Thank you so much. I wasn't aware of that utility at all. After running that utility on the app, it copies the required frameworks. but it does not change the rpaths of the executable.
ex: the otool -L still shows the default rpaths:
@rpath/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets (compatibility version 5.5.0, current version 5.5.1)
shouldn't they be changed to @executable_path/../Frameworks/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets
have I missed anything?
Yes, they should be changed as you suggested.
I had a look at an app I created and ran 'macdeployqt' on by running 'otool -l' on the executable. A small section of the rather long output looks like this:
... Load command 14 cmd LC_LOAD_DYLIB cmdsize 88 name @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (offset 24) time stamp 2 Wed Dec 31 19:00:02 1969 current version 5.4.0 compatibility version 5.4.0 ...
I have recently updated to Qt 5.6.0 but I haven't built anything yet (I suspect I have to modify 'macdeployqt' which I haven't done yet). From what I gather it only runs the various utilities provided by the OS anyway (such as otool and hdiutil) so it should do the same thing regardless of the version of Qt.
I guess the short version is that you are right, the rpath should be relative to the executable for anything included in the bundle.
AFAIK, no they don't (well, it depends on your Qt version). The rpath handling has been reworked recently so that you don't need to use @executable_path anymore.
You can check the Qt Creator bundled provided with the SDK.