How to setup Qt Creator to use windeployqt?

4.4k Views Asked by At

I am trying to compile my code in Qt Creator on Windows, and it compiles and runs in Qt Creator. However, when I try to run the exe from outside Qt Creator, I get errors about missing dlls.

From what I've researched so far, there are two options:

  1. Find these missing DLLs and copy them into the same directory as the exe, and hope to god I copied the right versions.
  2. Use windeployqt to automate (1).

Now I don't want to be dealing with windeployqt via the command line - is there a way I can get Qt Creator to take care of that for me? So far, when I click on Deploy, it just builds the project, but doesn't seem to do anything else.

1

There are 1 best solutions below

3
Soheil Armin On BEST ANSWER

You can run windeployqt with QMAKE_POST_LINK. Just set DEST_DIR to where you want to deploy your application and call the windeployqt on that directory.

Here is an example.

win32 {
DESTDIR = $$PWD/bin
QMAKE_POST_LINK =  windeployqt $$shell_path($$DESTDIR/$${TARGET}.exe)
}

With this implementation, it will create a bin folder in project folder, copies the target (.exe) to that directory and runs windeployqt on it. You are free to choose another directory relative to your project directory or an absolute path.