Solved Windeployqt copies wrong version dll files
-
I am trying to use windeployqt to copy the qt related dll files but always copies the wrong version of dll files.
On my Windows 10 system I have two version of Qt 5.14 and 5.15, later being installed recently.
Now I build my application using Qt 5.15 and try to run the windeployqt. And found that the Qt related dll are copied but the dll copied are of Qt 5.14
I have both version bin directories set in the system environment variables.
Does any one know from where does windeployqt copy the dll files and how does it know which version to copy ?
-
@jay1 said in Windeployqt copies wrong version dll files:
I have both version bin directories set in the system environment variables.
Fix it by only have one in your PATH.
-
@Christian-Ehrlicher But I need to have two version on single system, this issue didn't happen when I had Qt 5.13 and Qt 5.14. So I think there must be some way to control or configure this i.e. from where the .dll files are copied.
-
Hi,
You can have as many Qt versions you want, however, it's a bad idea to put them all in your PATH environnement variable.
If for some reasons an application fails to find the dlls it might end up using the wrong version rather than fail properly.
-
@jay1 said in Windeployqt copies wrong version dll files:
windeployqt
I think you can use
--dir <directory> Use directory instead of binary directory.
to tell it where to copy from.
Didn't test this assumption though. -
@SGaist you are correct we can have as many Qt Versions as we want.
I think it's still possible to having all of them in PATH environment variables.@mrjj This might be much more complex solution, implementing/modifying existing multiple projects is time consuming task.
If we have multiple Qt versions in our PATH enviroment variable, taking care of below to can be helpful:
- Make sure that the latest version of the '$QTDIR\bin' comes before the older versions.
i.e. 'Qt5.15/bin' comes before 'Qt5.14/bin'. Thus we are ensuring that always the latest version dll's are selected. - Make sure that existing multiple version of Qt, doesn't differ by the Major version change i.e. Qt5.15 and Qt6.0.
So as to ensure the Qt version compatibility.
Major releases may break backwards binary and source compatibility, although source compatibility may be maintained.
Minor releases are backwards binary and source compatible.
Patch releases are both backwards and forwards binary and source compatible.As currently my issue doesn't have major version, so change made to putting the latest Qt version in PATH before the older versions worked. The newer Qt i.e. 5.15 version dll's are copied which are compatible with Qt 5.14 executable files.
Qt Version Compatibility may be the key to this issue.
Reference: https://wiki.qt.io/Qt-Version-Compatibility
- Make sure that the latest version of the '$QTDIR\bin' comes before the older versions.
-
@jay1 said in Windeployqt copies wrong version dll files:
Make sure that the latest version of the '$QTDIR\bin' comes before the older versions.
i.e. 'Qt5.15/bin' comes before 'Qt5.14/bin'. Thus we are ensuring that always the latest version dll's are selected.If you do this, then Qt5.15/bin will always be searched first so Qt5.14/bin won't be searched. What is the purpose of having both in your PATH?
My other question is: Why do you need Qt in your PATH at all?
I think it's still possible to having all of them in PATH environment variables.
What if the user installs 2 different programs that are built with different variants of Qt 5.15? (For example, 1 program requires Qt 5.15 for MSVC 2019, and the 2nd program requires Qt 5.15 for MinGW 8.3.0)
-
If you do this, then Qt5.15/bin will always be searched first so Qt5.14/bin won't be searched. What is the purpose of having both in your PATH?
@JKSH The purpose is not to remove any existing environment variables. And yes you are correct it always searches the first occurrence of the Qt in PATH. This was intended so that we can take advantage of the Qt version compatibility.
For the question: "Why do you need Qt in PATH at all?". I don't need Qt in PATH variable to build my project, but other programs does need, so this cannot be removed from the PATH.
I was able to solve the problem by removing all the Qt/bin PATH variables.
Thanks for you response (helped to look at the correct content) -
@jay1 said in Windeployqt copies wrong version dll files:
For the question: "Why do you need Qt in PATH at all?". I don't need Qt in PATH variable to build my project, but other programs does need, so this cannot be removed from the PATH.
In that case, it means that they are not properly deployed and it's dangerous to have to rely on the presence of a development installation for an application to work properly. You should rather fix these programs installation.
-
@jay1 said in Windeployqt copies wrong version dll files:
The purpose is not to remove any existing environment variables.
...
I don't need Qt in PATH variable to build my project, but other programs does need, so this cannot be removed from the PATH.
I see. Like @SGaist said, those programs have not been deployed properly; please contact the program authors to ask them to rectify the issue.
A program's installer should not add any Qt DLLs to the system PATH. If they do so, they can break other programs that rely on Qt.