Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Could not load Qt platform plugin "windows"
I face a fairly common problem, only that mine seems to be even more deeper than anyone's of yet. I've created an application with Qt5, on my desktop machine. I grapped the .exe and all the .dll's required by DebugView. When I try to run it on my Surface Pro (Windows 8 Pro), I get an error:
@This application failed to start because it could not find or load the Qt platform plugin "windows"@
Now, I've tried everything I've came across:
- Added folder called "plarforms" in the directory of the .exe, with dll's:
Added a folder "plugins" and placed the platforms -folder there
Copied the whole plugins folder (although from my Surface's own Qt install, which is Qt5 also though, just
a version or two newer) to the application folder
Copied libEGL.dll to the application folder
Created qt.conf with the lines:
Also tried Libraries=./platforms
NOTHING seems to work. I also now got the same error on another machine, running Window 2008 Server.. I really need a solution for this, can anyone help? :(
The stuff you have tried seems to be correct, it should work. Please consult the "deployment guide":http://qt-project.org/doc/qt-5/windows-deployment.html. And try with dependency walker. We'll carry on from there.
Ah, by DebugView in the OP I actually meant Dependency walker :)
Thank you very much for that link, of course I had read it before, but now I read it really line by line. I now know the cause of my problem :)
When I first bundled my app, I grabbed all the Qt and rest of the DLL's Depency Walker showed, from my dev machine. I then tried to run the app on my Surface -> got the error -> Googled around -> copied the qwindows.dll from my Surface's Qt installation! I know took the qwindows.dll from my dev machine, placed in platforms -folder, and vóila, it runs.
Now, I do have a question though.. In my dev machine, I have two qwindows.dll's in my C:\Qt\Qt5.1.1 folder:
How do I know which one I should used? I now used the in the mingw48_32 folder, which worked. Should I always take the DLL's Depency Walkers tells me to, from that folder exactly, not from QtCreator folder?
Never take the one from Qt Creator: it is in no way connected with your code or Qt libraries.
I'll explain, but it might be a bit long :)
Qt Creator is designed to be an independent IDE. That means you can run and use it even when you don't have any Qt version or compiler installed on your machine. So, if you need it just for it's Python support, or you are interested in Qt Creator as an IDE for pure C++ projects, you can still use it. Also, if you have several Qt installations working in parallel, it is important that Qt Creator itself is in no way affected by them - that is, it should not link to any external Qt, as it would easily lead to numerous errors.
So Qt Creator - on all platforms - always bundles a copy of Qt libraries and (through some launch scripts) makes sure it is not influenced by anything thrown into PATH or LD_LIBRARY_PATH. The copies of Qt DLLs you find inside Qt Creator package are not ready to be redistributed, they are there only to make Qt Creator work.
Phew :) Hope it helps.
Thank you, I think I understand: because Qt Creator is created using Qt library, ofcourse the dll's inside it's folders are for itself! Right?
And yes, I do primarily use Qt Creator for all my C++ projects atm, I find it very suitable for all my needs. It's the best I've used so far, although I haven't really used Visual Studio yet... But for now I don't even want to, Qt Creator has everything I need!
Thank you once again, I'm pretty sure this is solved & I learned much else aswell.
You're welcome :-) Happy coding!