0

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?"

Anedar
  • 4,235
  • 1
  • 23
  • 41
  • This is an XY Problem. Don't try to force the tool to work a different way than how it is designed. You can already install multiple versions of Qt side by side, It's all documented here: https://doc.qt.io/qtcreator/creator-project-qmake.html – gavinb Sep 20 '19 at 13:13
  • Possible duplicate of [Installing multiple versions of Qt library](https://stackoverflow.com/questions/11434670/installing-multiple-versions-of-qt-library) – gavinb Sep 20 '19 at 13:13
  • I use neither QtCreator nor qmake. I use CMake, Visual Studio and windeployqt. And when calling windeployqt it has nonexistings paths stored somewhere... – Anedar Sep 20 '19 at 22:50

2 Answers2

1

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".

Former contributor
  • 2,466
  • 2
  • 10
  • 15
  • I found the hardcoded paths and edited them, but windeployqt used still the same paths afterwards. It looks like this documentation only says, that windeployqt will copy Qt5Core and edit the stored paths there. However your answer brought me on the right track... – Anedar Sep 20 '19 at 22:54
1

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.

Anedar
  • 4,235
  • 1
  • 23
  • 41