1

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 Answers1

4

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.

Soheil Armin
  • 2,725
  • 1
  • 6
  • 18
  • Thank you, this works! For DESTDIR, ideally it would go into wherever the Release build target is set. I could hardcode it, but I think there should be a variable defined for that. I can't seem to find anything about that here though: https://doc.qt.io/qt-5/qmake-variable-reference.html – Enter Display Name Here Jul 19 '21 at 02:33
  • @EnterDisplayNameHere You will need to do that. You need to hardcode your deploy path somewhere. It can be relative to any directory like what you do with DESTDIR. – Soheil Armin Jul 20 '21 at 11:29
  • Man, I love you. Honestly. Thanks for this... what about other platforms? Linux? Mac? Thanks a lot. – Mecanik Feb 13 '23 at 04:56