views:

409

answers:

3

Whats the best way to deploy a QT app? I've read the documentation hosted at trolltech but is it better to link with a static library or the dynamic libraries and have the user install the framework? I don't really want anyone using my app to have to download a 160mb framework just to run a simple gui frontend.

+2  A: 

On Linux, it's better to rely on the OS's copy of Qt, as it's almost certainly installed - for OS X, almost all apps use a statically compiled library.

Paul Betts
well I dissagree, most apps on Mac OS X include frameworks inside of app bundle
Kamil Klimek
@Kamil True - what's *not* a good idea though, is to try to install the framework system-wide; just a difference between the Windows / Linux way
Paul Betts
+1  A: 

Unfortunately you will have to include the Qt libraries you need into your own bundle, as you cannot expect your users to have Qt installed on Mac (whereas on Linux packaging systems allow you to require at least a given version of Qt.

There is a nice tool to help you with that, which is called macdeployqt. You just need to invoke it on your bundle application and it will pack the required libraries, changing the linkage of your binary to refer to them. Without it, making bundles for Mac is a real pain (it still is, but considerably less though).

http://doc.trolltech.com/4.6/deployment-mac.html#the-mac-deployment-tool

Afterwards, you can make a .dmg image as you would do with any other app. There is an option in macdeployqt that builds a basic one.

Gnurou
+1  A: 

On OS X it's a good way to do a dynamic build and post-process the resulting ".app" with the macdeployqt tool which comes with Qt starting with 4.5.

This will copy the Qt frameworks used by your application into the application bundle, which results in a larger package than building a static version of your application.

Here is what you can do to make sure you get the smallest file size possibly in a dynamic build:

  • First off, make sure you only include the stuff you need (in the project.pro file's QT += core gui network xml lines).
  • Open the application bundle and remove any unneeded "Qt Plugins" from the bundle. macdeployqt automatically compies all the Qt plugins in there, which can be kind of bulky.
  • Make sure you are building your application in release mode. Otherwise your application might be linked against the debug libraries of the Qt4 framework, and they are really big (for instance, well over 90 MB for the debug library vs. 16 MB of a release variant without debugging symbols). This might be what happened in your case.
  • If you have a large application binary, you can use UPX to compress your executable file by 40-50%.

Other than that, you should use compressed disk images to deploy your application.

One of my projects uses QtGui, QtNetwork, QtCore and QtXml and the resulting bundle is about 16 MB in size.

Hope that helps.

BastiBense