OwnBlog from DimiG    About    Archive    RSS

Qt static compilation for Windows

In this article, I have decided to talk a little bit about programming stuff. In programming forums I often to see the question - “How to make the static compilation in Qt”. What is Qt? Qt is a cross-platform application framework that is widely used for developing application software that can be run on various software and hardware platforms with little or no change in the underlying codebase, while still being a native application with the capabilities and speed thereof. Qt is currently being developed both by the Qt Company, a subsidiary of Digia.

Now I’ll give some links and will give some little explanation based on my own experience. Feel free to comment it below.

First of all you have to decide which compiler you’ll use for Qt (MinGW or MSVC). This solution is working only for Windows platform only. I use the MinGW (Minimalist GNU for Windows), so I limited by 32bit version and can’t use 64bit one. Qt officially setup only 32bit version of MinGW. How to use the MSVC for static compilation I don’t know. If you have experience feel free to write in comments below.

Long time ago, my programming trainer told us: “If you have questions - read documentation”. Fortunately there is brief official documentation how to do it HERE.

Compile such huge project as Qt is complicated task and it takes a lot of time to do. I do compilation on my computer during the half day. That is why the official documentation offer to use the script. Because of you use Windows it is logical to use the PowerShell script for that. This script is possible to download from official SourceForge project of THIS script developer - Thierry Lelegard. (See in the list below). It calls windows-build-qt-static.ps1.

Unfortunately THIS script didn’t work for me, so I had to tweak it a little. ;) Maybe you’ll be more lucky, cause author is still update it.

Also, don’t forget to setup the 7-zip archiver and setup it on your system before you’ll try to run this script. Create the C:\Qt\Static directory and check the Qt static environment (see documentation). Check the link to Qt source code. It MUST agree with your installed version of Qt and MinGW compiler version which MUST be installed via official Qt Maintenance Tool located on your system.

As you see the static compilation is NOT easy to do, but this beautiful script is saving our days. Thanks to Thierry. :)

I run this script from inside the C:\Qt\Static. Here is my Static directory structure for version 5.6.0:

Static/
├── 5.6.0
│   ├── bin
│   ├── doc
│   ├── include
│   ├── lib
│   ├── mkspecs
│   ├── plugins
│   ├── qml
│   └── translations
└── src

Good LUCK…