Aug 31, 2014

Deploying QML 5.3 Applications on Windows


First you should know there is a tool to help you deploy both Qt Widget and QML applications under Windows.  It’s called windeployqt.exe and it’s in your Qt bin folder. I constantly saw advice to run Dependency Walker but this tool is much better for QML application deployment.  This tool is mentioned on the Qt help page on deploying.

On my machine the Qt bin folder looks like this:


Before you run the tool, it will help to check your path environment variable and make sure the Qt bin folder  is in your path. Otherwise you’re going to just get errors about .dll’s that windeployqt.exe can’t find.  Also read this blog to the end and save yourself some frustration. 

Navigate with Windows Explorer to the Qt bin folder an then type cmd in the address bar to open a command prompt in this folder. I then type prompt % to reduce the prompt length to a single character (typing prompt with no parameter will restore it). You can get help on windeployqt by running it in the command line with no parameters.

My latest course on Qt Quick/QML is schedule to go live on October 24, 2014, in the meantime... Don’t miss my Pluralsight course – Introduction To Qt : A C++ Cross Platform Application Framework.

I copied my bin\release folder from my development area to near the root on my C drive. You don’t have to do this I just didn’t want to muck up my dev folders.  So I started with a folder path like this:


and ended with


The release folder contained my TargetSetter.exe file and a couple of other files.

When deploying a QML application you also need to specify the location of your .qml files. So I also copied my source development folder over to:


Then I ran the tool, that looked like this:

> windeployqt –qmldir C:\test\TargetSetter C:\test\release

This creates quite a bit of output and my C:\test\release folder had over 180 files when it was done. I copied this folder to a new computer and ran but no joy. The tool appears to create flawed copies of two of the DLLs. I got an error dialog with the message

“libwinpthread-1.dll is either not designed to run on windows or it contains an error.”

I just replaced the versions of the .dll that windeployqt.exe created with the versions in the Qt bin directory and then it worked. 

I was curious at this point to see if the folder size could be cut down. While the .exe was running I started deleting .dlls and other files. I did it in stages. Several times I got warnings that .dlls were in use so I just skipped them. It’s a pretty fast way to find out what’s really needed and what’s not but you do have to be careful. As I moved into subfolders and deleted files the .exe eventually wouldn’t launch. I did it in stages so I could easily restore to a working version and winnow down the files. When I was done the folder that started at 90 MB was down to under 60.

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.