Solved Impossible to deploy Qt applications
-
I am having serious troubles in trying to deploy my new application built with Qt. The program runs fine when started from Qt Creator (all builds: debug, profile, release), but it crashes when started by double clicking on the .exe. An error dialog pops up with the following message:
?defaultTypeFor@QTimer@@CA?AW4TimerType@Qt@@H@Z could not be located in the dynamic link library C:\Users\SDT1\Documents\Scanner\Scanner_deploy\Scanner.exe
I am using Qt 5.8.0 and I am building the project with MSVC2015_64 bit. I am using windeployqt.exe from C:\Qt\5.8\msvc2015_64\bin to dinamically link the Qt libraries.
This problem started happening since I moved from the old connect syntax (with the macros SIGNAL and SLOT) to the new one with function pointers. I also started using QTimer::singleShot instead of QMetaObject::invokeMethod, and not surprising the error involves QTimer. However, the program works just fine from inside Qt Creator and I can't figure out where the issue is, since I am using windeployqt to get the right dlls.
Also, why my .exe is referred to as "dinamic link library" in the error message? It's an .exe!
-
Any chance it get hold of wrong Qt lib ?
If possible test the deployment folder on a clean install. ( use virtual machine)
Also double check that all needed DLLs were copied with windeployqt
-
Hi @mrjj , thank you for your reply. I solved the issue, but I'm still not sure what was going wrong: my Path variable was pointing to the folder of Qt version 5.7 (the only other version I have). I changed it to 5.8, rebooted and redeployed and it DIDN'T work. Then, I deleted the build folder, rebuilt and re-deployed and it DID work. So, the problem was with the build.
However, how can this happen? I changed back the Path to Qt 5.7 and rebooted to make some tests. The problem appeared again, but I don't understand how the Path affects the build. Despite having Qt 5.7 in the Path, in Qt Creator the Compile Output shows all the Qt stuff pointing to the 5.8 folder (qmake.exe, uic.exe, include folders, ...). There is no reference to version 5.7. Only jom.exe is not from the Qt 5.8 folder, since it is in the Qt Creator folder. Maybe it's it that loads something from Qt 5.7, by looking at the Path? In the build toolchain, who uses the Path and who doesn't?
-
Hi,
That's because Qt Creator modifies internally the PATH environnement variable so that you always use the Qt version you're building your application with.
Modifying your PATH environment variable globally like you are currently doing is really a bad idea.
-
Hi @SGaist ,
I want to understand this, could you give me a few more details, or could you point me to some web content where I can find the relevant info?
- Why is it a really bad idea to change the variable globally? What can happen in practice?
- This solved the issue, and if I change the variable back to 5.7, the problem appers again. What should I do to solve it then?
- Why the new Qt installation didn't update the global variable? What is the point of having a variable pointing to 5.7 if I use 5.8 all the time now?
- Which parts of the Qt ecosystem use that global variable?
Thank you!
-
- Because all of a sudden, Qt application not finding one of their .dlls in the same folder as their executable will load the one they can find using PATH. Which is not something you want on any system.
- Don't put your development Qt binary folder in the PATH environment variable.
- The Qt SDK never touches that variable system wide.
- None
The installation of the Qt SDK is self-contained and doesn't touch PATH system wide. Like I wrote before, Qt Creator modifies that variable internally to run your application. It does not touch anything system wide.
-
Ok thank you. I deleted the global variable and it works. I didn't think about deleting it because I thought it was supposed to be there. I didn't put it there, and I assumed that the installer did it. If the installer didn't put it there, then who did?
Thank you for your help!