Qt static linking and deployment

I wrote a guide to static linking

and
How to build Qt static with multiple compilers and keep it small

(because it can get pretty big, especially for simple programs).
You may also want to check out the BitRock installer, which is free for open source projects.

In short, it turns out to be a little more complex if you are using anything Qt thinks of as a plugin, such as support for most image types (JPEG, GIF) or databases.
For example, if you want to include support for Oracle DBMS and GIF images for your icons, you add the following to your .PRO file:

QTPLUGIN += qsqloci qgif
CONFIG += static

You will then need to:

#include <QtPlugin>

in your project, and import any plugins used. You need to change these settings back order to get it to compile with dynamic linking again (like when debugging or adding features), though this can be easily automated. There are also considerations when building the Qt libraries for use with static linking, though the Qt instructions will at least get you started.

Leave a Comment