Archive

Posts Tagged ‘Qt’

Deploying Qt 4.x applications on Mac and Windows

April 28th, 2010 Comments off
If you are using Qt as your development tool – most likely you are targeting different platforms. Deployment techniques for different platforms vary and there are a few “gotchas” that you should be aware of.
For OSX – you should use the macdeployqt command that comes with Qt on OSX. To use it – simply go into the folder where your application is and run the tool giving it your app name as the parameter.
macdeployqt Foo.app
This packages everything nicely into one bundle that you can distribute to someone who does not have Qt installed on their system. I assume that this build is a “Release” build and I assume that you will be able to either create an installation package or an installable .dmg file
On Windows – things seem to be simple at a first glance as well, but there are a few things you should pay attention to.
Copy your .exe into a new folder and try to run it. You will immediately get a note about some missing dlls. You can keep trying this and copying the dlls needed into the folder, but a better way is to use Dependency Walker tool and drop your executable into it. It will show you most dlls you need to run the application.
The fun starts when these modules are loaded on demand in the application’s code. This is the case with the Qt “plugins”. They will not show on your dependency tree and your application may appear to be running, while in fact it will crash or worse – continue to work without desired functionality when these plugins are required and you are NOT on a machine that has Qt installed.
The real trouble is that Qt will look for those in a specific folder within your application AS WELL AS the main Qt plugins folder – this makes your installation impossible to test unless you are on a machine that does not have Qt installed.
An example of this are the Qt image processing plugins that allow you to load various file formats into a QImage object.
Plugins are located under the “plugins” folder in your main Qt installation folder. Within that folder you will have subfolders for each group of plugins. For image processing – the name is “pluginsimageformats”.
To make this available on the target machine – you have to place the folder called “imageformats” under the main folder where your executable file is. So if you are installing your application into “C:Program FilesMyGreatAppMyGreatApp.exe – you have to install a folder “C:Program FilesMyGreatAppimageformats” into it and copy all the dlls you need there.
So – it’s really easy to deploy a Qt App on Windows or Mac, but watch for a few of these little tricks. Always test your build on a machine that does not have Qt Installed before deployment. (something I didn’t do last time and a reason for this blog entry :))