Qt application tries to load the wrong platform plugin
I have build a small program and I'm trying to deploy it to my second computer. When I start it on my second computer I get the error:
This application failed to start because it could not find or load the Qt platform plugin "windows". Available platform plugins are: minimal, offscreen, windows, windows. Reinstalling the application may fix this problem.
After a bit of experimenting it turns out it is trying to load the platform pluging from the Qt sdk in the folder C:\Qt\5.4\mingw491_32\plugins\platforms. And since it is a different revision of qt it cannot load that plugin. When I move this folder away my application just starts normal.
How can I fix this so my application will run normal without messing up my qt install?
The application is build with qt 5.4.0 mingw491_32. On my second computer, where I try to run the application, I have Qt 5.4.1 mingw491_32
Hi and welcome to devnet,
Did you properly deploy your application ? e.g. using windeployqt ?
I did. And when I deploy it the same way to a different computer that does not have a qt sdk installed it just works.
Hi, this is an unfortunate side-effect of the installation of Qt; the directory you specify when you install Qt is written into Qt5Core.dll. The plugins subdirectory is stored in Qt5Core.dll as well (in Qt v5.4 not in v5.5) and in your case that's C:\Qt\5.4\mingw491_32\plugins.
This is for helping Qt Creator launch your application, i.e. when your app starts it looks for plugins in the directory written in Qt5Core.dll and in 4 other places, I write more here.
And because you have the same installation path on both PCs but different Qt versions you get this funny error. 2 ways to solve this I think:
- Reinstall Qt on one of your PCs with another path than C:\Qt\5.4\ming491_32
- Binary edit the copy of Qt5Core.dll that windeployqt puts into your directory, so that the path points somewhere else (there is an editing example in my blog post in the link above).