How to build static Qt application on Windows (even with Qt Creator)

I started working on a new Qt project and everything went very well. But once the project reached a good state, I had to start publishing builds of my application. Most Linux users have Qt installed, or they can install it very easily (usually it’s available in their repository). But it’s a different story on Windows.

In most cases, you want a static built Qt program. Because it will run just fine by itself, without the need of installing anything else.

Solution:

  1. Install MSYS2: http://www.msys2.org/
  2. Update the system, with “pacman -Syu”, and install all the packages. Once the update is done, open up Task Manager and kill “bash.exe” and “pacman.exe”.
  3. Install the recommended packages ( https://wiki.qt.io/MinGW-64-bit ):
    pacman -S base-devel git mercurial cvs wget p7zip
    pacman -S perl ruby python2 mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain
    pacman -S mingw-w64-i686-qt5-static mingw-w64-x86_64-qt5-static
  4. Install Qt Creator (yes, trust me on this one):
    mingw64/mingw-w64-x86_64-qt-creator
  5. Done!

Now you can simply start Qt Creator from the MSYS folder. Located at: msysfolder/mingw64/bin/qtcreator.exe
This Qt Creator will detect the static Qt installation in the msys folder, and you can already compile your project, because this Qt Creator will use your existing Qt Creator settings. You can simply switch between the two Qt Creators, they will cause no issues whatsoever. Just switch “build configuration” at the bottom-left, and that’s it.

This setup provides an easy, robust static Qt compilation environment.

Leave a Reply

Your email address will not be published. Required fields are marked *