Deploying Qt Applications on Windows

Windows users should have to perform 4 steps if they want to use my Qt desktop program.

  1. Install the MSVC redistributable package.
  2. Download a zip file from my website.
  3. Extract the zip file.
  4. Double-click the executable.

I make no assumptions about what is already installed on their machines. I can use an installer to remove the burden of installing the MSVC package, but for now I’ll do this manually.

Development Setup and Test Program

My development setup is as follows.

  • Visual Studio 2010
  • Qt SDK 5.1.1 (OpenGL) for MSVC2010 32-bit

To make this as simple as possible, I simply created a brand new GUI project in Qt Creator, and changed no settings whatsoever from the wizard’s defaults.  I modified no source code, and ran the program once in Release mode inside of Qt Creator in order to produce the binaries.

Target Machine

I’m using VMWare in order to test each zip file I make to see if it will run on a clean install of Windows 7 x64 Home Premium.

Create the Zip

I’m going to use absolute paths, but obviously you should substitute your own as appropriate.

  1. Create an empty folder that will house your executable and associated DLL files.
  2. Copy the release .exe into the folder. You do not need the manifest file.
  3. Go into C:\Qt\Qt5.1.1\5.1.1\msvc2010_opengl\bin 
  4. Copy any required DLLs and paste them next to the .exe in your new folder. If you are running into problems, just copy all of them in order to eliminate this step as a source of problems. Once you get everything working, you can prune out unnecessary DLLs using Dependency Walker. For the default test application, I needed: Qt5Core.dll, Qt5Gui.dll, Qt5Widgets.dll, and all of the dll’s prefixed with “icu.”
  5. Go into C:\Qt\Qt5.1.1\5.1.1\msvc2010_opengl\plugins\platforms
  6. Copy qwindows.dll and paste it in <your new folder>\platforms. You have to perform this step for all applications, even if you don’t know what plugins are or don’t think your application is using any.
  7. Compress your new folder.

Finding the Right Redistributable

It turns out that Qt packages the appropriate redistributable installer with itself. Instead of hunting around for it on the internet, just use theirs.

  1. Go into C:\Qt\Qt5.1.1\vcredist
  2. You should see something like vcredist_sp1_x86.exe.

Final Process for End Users

After uploading the zipped installation folder and the corresponding redistributable provided by Qt, the installation process on the VMWare Windows 7 x64 machine looked like the following.

  1. Download vcredist_sp1_x86.exe.
  2. Run the installer, using all default settings.
  3. Download the zipped installation folder.
  4. Unzip.
  5. Double-click executable.

Conclusion

Getting this to work took me longer than expected, but that was due to two problems. First, having multiple Qt installations on my development machine must have resulted in me copying the wrong dll’s or using the wrong version of Qt Creator, or something. Uninstalling all versions of Qt, deleting the corresponding folders, then installing only the version I wanted to use made debugging much easier. Second, attempting to find the MSVC redistributable package on the web was difficult. It was never clear if I was downloading the right version; finding and using the one provided by Qt helped tremendously and worked the first time.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.