How to Deploy a Qt Application on Windows

How to release a Qt/C++ application on Linux and Windows?

There are several ways to deploy your application

1. Deploy your application with windeployqt/linuxdeployqt

This is the easiest way, windeployqt or linuxdeployqt is an application that will copy all required dependencies to your executable folder. Ready to run on another computer.

The steps are simple:

  1. Compile your binary in release mode
  2. Open the Qt developer console and type windeployqt "C:\folder\of\your\executable" (linuxdeployqt will be very similar)
  3. All libraries required to run the application on another computer are copied to to your application folder. You can create an archive and send it to someone else.

Note: linuxdeployqt is third-party.

2. Static build

Static build will be a single binary at the end that includes all Qt code. You can ship your single binary to someone, no additional libraries are required to run it. The executable is larger since all the Qt code is linked inside your executable.

The steps are as following:

  1. Download the Qt source code
  2. Unzip it to a folder
  3. Open the developer console of your installed compiler (i. e. MingW or MSVC)
  4. Switch to the folder and type

    ./configure -static -static-runtime

  5. When the configuration is done type nmake or make to build Qt statically.
  6. When the build process has finished create a new kit in Qt Creator and select the new qmake.exe or qmake from your source-code folder.
  7. Select in the project settings your kit to build a statically executable that requires not additional libraries.

3. Offline/Online Installer

This step requires some reading and fine tuning. Qt comes with an IFW (Installer Framework) where you can create online and offline installers. The installer will contain a .7z file of your executable and all dependencies. The installer is more comfortable for the user. It can create shortcuts, check available disk space, etc.

IIRC you need build the installer statically for MSVC or you have to ship the runtime libraries. If build with MingW you probably will not need any runtime libraries.

It is up to you which method you choose. If you own the commerical license you can ship all your closed source as static builds, but in general it's better to ship it as a dynamic build especially if you use OpenSSL where users can quickly exchange vulnerable libraries themself if required.

Deploying Qt 5 App on Windows

After some hours digging in the Qt Forums, I found out that I need to copy the "qml" folder (normally located in C:/Qt/5.2.1/qml) to the application's root directory. After doing so, both the dynamic and static versions of my application worked on vanilla systems.


Program directory (MinGW 4.8 32-bit, dynamic):

As hyde said, use the windeployqt tool (<qt path>\<version>\bin\windeployqt.exe) to copy the necessary files to your application's folder. After that, copy the required QML components from <qt path>\<version>\qml\ to your application's folder. The resulting folder should look similar to:

  • platforms (folder)
  • QtQuick (folder)
  • QtQuick.2 (folder)
  • Any other QML components that you need
  • app.exe
  • icudt51.dll
  • icuin51.dll
  • icuuc51.dll
  • libgcc_s_dw2-1.dll
  • libstdc++-6.dll
  • libwindthread-1.dll
  • Qt5Core.dll
  • Qt5Gui.dll
  • Qt5Qml.dll
  • Qt5Quick.dll
  • Qt5Network.dll
  • Qt5Widgets.dll

Program directory (static)

Compile the application statically, then copy the required QML components from <qt path>\<version>\qml\ to your application's folder. The resulting folder should look similar to:

  • QtQuick (folder)
  • QtQuick.2 (folder)
  • Any other QML components that you need
  • app.exe

I think the cause for the crash was that the Qt5Gui.dll (dynamic and static) "tried" to load the QtQuick* folders during run time, but could not find them (thus crashing the application during load).

Single setup exe file Qt Application deployment

==>Static Compilation for Windows -

https://www.youtube.com/watch?v=lwX_urJJOf8

==>Static Compilation for Mac/Linux -

https://retifrav.github.io/blog/2018/02/17/build-qt-statically/

How to deploy a qt based app(developed on Mac) to Windows?

you have to recompile it on windows. you have to make sure your code doesn't use macos "framworks" or unix or linux specific functions.

i recommend downloading a precompiled static QT as building it is impossible. you can get that here and using the visual studio compiler, you will have to download visual studio and all the c++ addons and stuff.

!! edit what ever directory your cmd is in is the output of the qmake !!
you then open up cmd and run the static compiled QT's qmake on the .pro file of your project. e.g.

E:\QT_projects\QT\qt5-5.7.1-vs2015\qt5-x86-static-release\bin\qmake.exe E:\QT_projects\variable-length-string-editor-for-binaries\StringEditer.pro

that will make the makefile. and then open the visual studio cmd called "Developer Command Prompt for VS 2017" for me opening the start menu and typing it in will show it.

you then navigate to the folder where the make files that qmake generated e.g.

cd E:\QT_projects\variable-length-string-editor-for-binaries

then run nmake on release or debug or just nmake e.g.

nmake release

How to deploy a Qt application on Windows?

The Qt documentation has pages for that:

  • Qt 5,
  • Qt 4.

How to deploy my application using Qt-Creator?

You also need to deploy the MINGW runtime dll (mingwm10.dll). This file is located in your Qt\2009.5\mingw\bin directory.

Also pay attention to whether your application is compiled in debug mode or release mode. I just made the test with an hello world type application and Qt Creator. In the debug folders, I copied libgcc_s_dw2-1.dll, mingwm10.dll, QtCored4.dll and QtGuid4.dll and it works.

Pay attention to the d in dll names, which stands for debug: QtCore d 4.dll.

See Qt 4.6: Deploying an Application in Windows.
For Qt 5, check this page.

Deploy Qt program to Windows from Linux

You're missing several files needed around the executable.

Get them under "Qt Dir \ Qt Version \ MinGW Version \ plugins \"

Required :

  • imageformats\

    • qgif.dll
    • qico.dll
    • qjpeg.dll
    • qwbmp.dll
  • platforms\

    • qwindows.dll (that's what the error is talking about)

(if in Debug mode, use these files with a "d" at the end, for example qwindowsd.dll)

I'm not sure about the imageformats, but I had to use them even in programs not using pictures. Try with "platforms\qwindows.dll" first, then add the imageformats if the programs asks to.

See https://doc.qt.io/qt-5/windows-deployment.html for the full info and more precise options. I'm just giving you the explanation.



Related Topics



Leave a reply



Submit