Deploy an Application on Windows

From Qt Wiki
Revision as of 15:16, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Deploy an Application on Windows

This guide is written for Qt 5. It assumes that:

  • The release version of your app works correctly when you build + run it from Qt Creator
  • Your (dynamically-linked) copy of Qt is installed in C:\Qt\5.2.1\mingw48_32\

Overview

To deploy a Qt app, you’ll need to gather files from a few different locations. Here is an example of an app that uses Qt Quick to display a picture (NOTE: PACKAGE-SPECIFIC DLLS ARE NOT SHOWN):

Where to find files for deployment

Finding the Required Files

See Qt for Windows – Deployment [qt.io] for the official instructions.

Sometimes though, the deployment might seem successful and your app launches, but some things don’t work properly. Perhaps a window is blank, an image doesn’t show, or a music file won’t play. If this happens, you are probably missing a file that is only loaded at runtime (like a plug-in DLL).

These files can be tricky to identify. Here is a systematic way to deploy successfully.

Initial deployment (Quick and dirty)

  1. Close Qt Creator.
  2. Copy the following into C:\Deployment\
    1. The release version of MyApp.exe
    2. All the .dll files from C:\Qt\5.2.1\mingw48_32\bin\
    3. All the folders from C:\Qt\5.2.1\mingw48_32\plugins\
    4. (If you used QML) All the folders from C:\Qt\5.2.1\mingw48_32\qml\
  3. Rename C:\Qt\ to C:\QtHidden\. (This turns your PC into a clean environment, just like one that doesn’t have Qt installed.)
  4. Launch C:\Deployment\MyApp.exe.

If your app worked correctly, congratulations! You are almost ready for deployment. You don’t want to ship a 1.5GB package though, so it’s time to clean up unused files.

If it didn’t work correctly, ask for help (see the Appendix)

Final deployment (Cleaned up)

Do the deletion steps below in C:\Deployment\ and all of its subdirectories. After each deletion, launch C:\Deployment\MyApp.exe and test it. If it stops working, restore the files you just deleted.

  1. Launch MyApp.exe. While it is running, try to delete all DLLs. The DLLs that aren’t used will go to the recycle bin, leaving behind only the DLLs that you need. (This trick doesn’t work for .qml and qmldir files, however).
  2. (If you used QML) Delete a few .qml files and try relaunching MyApp.exe. Repeat until you try all .qml files.
  3. (If you used QML) Delete qmldir files from the folders that have no more DLLs or .qml files

When you have removed all the files that you don’t need,

  1. Rename C:\QtHidden\ back to C:\Qt\ to restore your installation.
  2. Distribute your app.

Appendix: How to ask for help

If you still get stuck,

  1. Start a new post in the Qt Project forum [qt.io]
  2. Say that you followed this guide. Say which attempts passed, and which attempts failed.
  3. Describe how it fails, and provide any error messages that you see.
  4. Provide a screenshot of the contents in C:\Deployment\

Remember: The more info you provide, the better your chances of getting a solution!