Where does windeployqt.exe store the Qt directory?

1.3k views Asked by At

When trying to run windeployqt.exe, how does it know where to look for the Qt Libraries?

I'm using Windows, Qt 5.3, msvc2013_opengl.


I have the following setup:

  • Qt was first extracted to C:/PathA/Qt/5.3. It worked fine there.
  • I copied Qt to C:/PathB/Qt/5.3
  • I then renamed the folder C:/PathA/ to C:/PathC/ to "hide" the old place.

When running C:/PathB/Qt/5.3/.../windeployqt.exe it complains, that it can not read file C:/PathA/.../QtPrintSupport.dll - of course, because that file does not exist anymore....

I tried:

  • overriding environent variables locally in a shell.
  • Removed all occurences of PathA from environment variables and rebooted.
  • Searched registry for PathA.
  • Checked qt.conf in both PathB and PathC - both contain relative paths.
  • Checked the source code of windeployqt - it seems to call qmake -query.
  • Called both qmake.exe -query - they return PathB and PathC as expected.
  • Changed the paths in both qtenv2.bat.

Still, windeployqt insists on searching C:/PathA - so where does it get that value from?


PS: I know that i could try to uninstall all Versions of Qt, get rid of everything Qt-related and reinstall it from scratch. However thats not what i'm interested in. I'm interested in allowing multiple Versions of Qt installed next to each other and controlling, which one to use (Using CMake and Visual Studio).


Edit: In contrast to this question, i'm not using QtCreator and the scope of this question is not "How to install multiple Versions of Qt when using QtCreator?". The question is specifically "Where does windeployqt.exe get the path to the Qt libraries?"

2

There are 2 answers

1
Former contributor On

Quoting this page:

windeployqt takes an .exe file or a directory that contains an .exe file as an argument, and scans the executable for dependencies... Identified dependencies are then copied to the executable's directory. The hardcoded local paths in Qt5Core.dll are furthermore replaced with relative ones.

So probably you are looking for these hardcoded paths in Qt5Core.dll, you may use an hex editor to look for "qt_prfxpat".

0
Anedar On

As far as i can tell, the order is this:

  • If a qmake.exe with a qt.conf file is found in one of the directories in PATH, windeployqt uses <path to qmake&qt.conf>/<prefix in qt.conf>/bin
  • else if a qmake.exe is found in the same directory as windeployqt.exe, the hardcoded path qt_binspath in qmake.exe is used
  • else if a qmake.exe is found in PATH, the qt_binspath there is used
  • else windeployqt fails with "Unable to query qmake: CreateProcessW failed"

Thanks to Pedro for his hint about the hardcoded values and the suggestion to use a hex editor.