Deploying Qt-based frameworks made simple
May 10th, 2009
Last time when I was deploying a Qt application on MacOS X I spent several hours struggling with otool and install_name_tool to make my app see all the bundled Qt frameworks and plugins. Then I found out that there is a dedicated tool for it, called macdeployqt and, what is more, it’s nothing new. To be honest, it’s so well known that it is currently shipped together with Qt. Shame on me.
Great then, macdeployqt reduces the deployment work to one line in terminal, and time thereof to several seconds :) However, my application, apart from Qt frameworks uses other custom, self-made frameworks that depend on Qt. It seems that macdeployqt doesn’t support deploying frameworks, as it searches for application binary located in <bundle_name>/Contents/MacOS, which simply doesn’t exist in a framework bundle. So I created a simple script, called frameworkdeployqt.pl that does the dirty work of deploying frameworks written in Qt. The basic concept is:
- you want to deploy a Qt application on MacOS X,
- your application uses custom/self-made/third-party frameworks written in Qt,
- all the frameworks are going to be located in
<bundle_name>/Contents/Frameworks.
Then you deploy the application in two simple steps:
- run
macdeployqtto copy needed Qt frameworks to the application bundle and adjust its internal framework references, - run
frameworkdeployqt.plto make your custom frameworks use Qt frameworks bundled with your application. You’ll of course need perl, but it comes out of the box with MacOS X.
The script looks for non-Qt frameworks inside the bundle given as an argument (namely, it searches <bundle_name>/Contents/Frameworks for frameworks other than Qt*) and then replaces their references to Qt frameworks so that they point to the ones that macdeployqt have just copied to the bundle. For now it’s a bit dumb, i.e. it doesn’t check the existence of Qt frameworks, so if your custom framework uses other Qt modules than the application (or macdeployqt somehow failed to copy them), you’ll have to copy them manually to the bundle.
Other drawback is that you can’t create a dmg image directly using macdeployqt, but anyway, if you happen to need frameworkdeployqt.pl, that dmg would have been useless for you.
The script is available from GitHub. Enjoy!

September 2nd, 2009 at 03:34 PM
Version 4.5 does support the -dmg flag which creates a .dmg from your .app. It seems to not package the translations, but it does automate a bunch of icky stuff.
September 10th, 2009 at 01:19 PM
Yep, actually what macdeployqt does also is it packages frameworks installed in system to your bundle. But when you have a project that compiles a framework and an application that uses this framework (without installing it), macdeployqt won’t figure out this one. And that’s the situation that my script is meant to handle :)
February 7th, 2011 at 12:57 PM
Thanks for the feedback, actually there’s no mailing list yet (and I don’t have your e-mail :) ), but you can track this blog, I’ll be posting updates here.
February 24th, 2011 at 11:57 AM
Version 4.5 does support the -dmg flag which creates a .dmg from your .app. It seems to not package the translations, but it does automate a bunch of icky stuff.
March 21st, 2011 at 01:56 PM
I certainly enjoyed the way you explore your experience and knowledge of the subject!
July 21st, 2011 at 11:34 PM
This is a great post! Ive always had problems with these kinds of frameworks. More things like this pls!
August 8th, 2011 at 11:09 AM
Thanks, now I understand it a bit better.
August 16th, 2011 at 07:03 PM
Great. Thanks for this post. Makes it alot easier.
August 19th, 2011 at 11:57 AM
Yes, in fact, even frames macdeployqt packs installed in the system package. But when you have a project that brings together the framework and applications using the framework (without installing), macdeployqt can not find it. And the situation is that my script is designed to handle:)
September 7th, 2011 at 07:15 PM
Thank you for sharing this information about Qt basked framworks with us. Post more of this kind and ill be back.
September 16th, 2011 at 11:23 AM
Your site is good Actually, i have seen your post and That was very informative and very entertaining for me. Thanks for posting Really Such Things. I should recommend your site to my friends.buy triactol
September 16th, 2011 at 03:37 PM
Hello,
I am working on qt-creator plugins. There is a option in qt to create app-bundle. If we use CONFIG += app_bundle then it will create bundle for your application. I found that it is not creating plugins folder in side app_bundle. Do we need to specify what are the dynamic libs the application is depend on.
1. Is there any qmake option for that? 2. If there is no qmake option for that then does macdeplyqt will help me by copying necessary dynamic libs in my app bundle for example myapp.app/Contents/Plugins directory.
When i run otoool -L myapp then it is providing the list of libraries it is depending on.
So will macdeployqt will help me by copying necessary libraries automatically in myapp.app/Contents/Plugins folder?
Please suggest me.
Br, Krishna
November 7th, 2011 at 04:58 PM
Great post. Very very interesting. My eyes were glued to the screen from the beginning to the end. Loved the first and the last topic. Thanks for sharing the information with us.
November 8th, 2011 at 10:38 PM
again very good information! thanks alot!
December 21st, 2011 at 08:24 AM
I tried that tools too, but unfortunately it didn’t work with me.