1

I have been using Qt for a while on Linux and Windows. However, yesterday I picked up a new MacBook Pro so naturally I've been playing around to see if I could build my Qt apps on Mac.

I got pretty much everything working, however there is one problem : the file size of the resulting app bundle.

I am building my application like this:

qmake -spec macx-g++
make
macdeployqt my.app -no-plugins -dmg

The bundle and everything seem to work fine, but, the generated .app is 31.1 MB large and the .dmg is 13.6 MB!

Is this normal? Can I reduce this horrible size (on Windows, my installer for the same app with all the libraries is ~4 MB)?

houbysoft
  • 32,532
  • 24
  • 103
  • 156

2 Answers2

2

If you are using the pre-built Qt libraries then the chances are that they are universal binaries with multiple architectures. For example, do $ file my.app/Resources/Frameworks/QtCore.framework/Versions/4/QtCore and you will see multiple architectures.

You can build your own Qt libraries with only the architectures that you want to support. You may wish to not support PPC because that is ancient; or if you are using a current Qt then you can make the decision of 32 bit vs 64 bit, but that's another question.

koan
  • 3,596
  • 2
  • 25
  • 35
0

The problem is the size of the Qt dynamic libraries, as they must be part of your bundle.

These sizes can usually be reduced. See the solution of How do I make apps smaller with qmake and macdeployqt on how to do this.

An excellent workaround would be a static build of Qt and linking your application against the static build. This usually is a very good idea as two applications installing Qt dynamically usually crash on Mac OS. Your application will have with static build (from my exp.) approx. 10-20MB of size. Combined with the steps above, some more reduction might be possible.

Community
  • 1
  • 1
Jens
  • 6,173
  • 2
  • 24
  • 43
  • Two apps using dynamic libraries are just as likely to crash on Windows, aren't they ? But it's the same risk that one app needs a different version of the same library because it has been updated more recently. You can install a central dynamic lib if you are willing to manage these situations just as on Windows. – koan Jul 11 '11 at 12:17
  • But Mac OS has the habit to load BOTH dynamic libraries, which makes Qt crash for sure, as the static variables of Qt are duplicated and the app uses a (randomly chosen) version of the loaded library which makes the static variables inconsistent after a short time. Windows loads only one version which is ok and consistent all the time. Qt was primarily designed for Windows and the other OS were later added which sometimes strange behaviour. – Jens Jul 11 '11 at 13:55
  • @Jens: what do you mean by "two applications installing Qt dynamically"? Aren't the libraries usually inside the .app bundle? How can two applications' Qt versions interfere, since each of the applications has its own copy in its .app folder? – houbysoft Jul 12 '11 at 22:39
  • Just like in Windows - there are tools, which hook into the system and present some computer wide service which thereby gets dynamically into other programs - I'm maintaing an open source program and have exactly this problem with some other free software - I can test it tonight at home, what it was, something with picture processing and plugins. – Jens Jul 13 '11 at 09:25