andseg
andseg

Reputation: 698

(Qt 5.7.0) Could not find or load the qt platform plugin "windows"

Bear in mind that all of this is with Qt Creator (5.6.1 and 5.7):

I have a project made in my work machine (Win7, 64bits, compiled with MinGW 5.3.0 32bits in Qt 5.6.1). It works perfectly both in debug and release mode.

Soon after, I decided to test my program in another machine (WinXp, 32bits). I just passed the executable and the .dll. Still working like a charm.

Later, i tested the SAME version of my program in my gaming machine (Win10, 64bits). Weirdly, it didn't work at all. I received the following error:


"could not find or load the qt platform plugin "windows"".


I remembered that if there is a .dll missing, this error occurs. So I passed all the .dll from Qt folder to my program folder (with the intension of deleting the unwanted latter). Much to my surprise, it still didn't work. But the error was diferent:


"could not find or load the qt platform plugin "windows"... Available platform plugins are: minimal, offscreen, windows, minimal, offscreen, windows."


It very clearly found the platform plugin windows (either qwindows or qwindowsd... or both in that matter), but it could not load it. Any ideias why?


EDIT: All .dll in C:\Qt\5.7\mingw53_32\bin was copied and pasted to the folder with the executable.

All folders in C:\Qt\5.7\mingw53_32\plugins were copied and pasted to the folder with the executable.

Thats pretty much all the .dll I added!

Upvotes: 4

Views: 9372

Answers (4)

rsood
rsood

Reputation: 73

The answer that says you need a "platforms" directory that contains qwindows.dll inside the directory that contains your application is correct. Importantly, it must be directly inside your application directory, i.e. ./platforms/qwindows.dll, not inside another directory within your application directory, such as ./plugins/platforms/qwindows.dll

This is documented in the Qt 5.7 documentation; in Qt Creator, go to help and look up "deployment". There is also some discussion here about how to change the place your application will look for this and other libraries.

I was having this same problem; I have verified this solution works by putting my app and the DLLs it depends on, as well as a folder named platforms containing qwindows.dll, in a directory on a flash drive and opening the app on a computer that did not have Qt installed. The app opened fine.

Upvotes: 1

andseg
andseg

Reputation: 698

WHY THE PROBLEM OCCURRED

Honestly, I don't know. But it very much seems like "Alexander Saprykin" answer is correct. During the process of testing, i had to update my Qt so it could fairly well be only a version mismatch.

Also, the fact that when I redid my build using only Qt 5.7.0 it worked, implies that it was indeed only a mismatch case.

HOW I FIXED IT

As told by "Sebastian Lange" in the comments, using windeplyqt.exe did the job. I just deleted everything but the .exe in my build folder, opened Qt5.7 command line, chaged directory to the same as my .exe and ran the command windeployqt . or windeployqt [name_of_exe].exe

Thanks to everyone!

Upvotes: 10

Alexander Saprykin
Alexander Saprykin

Reputation: 581

You have said that app was compiled with Qt 5.6.1, and you have also copied all .dll files from Qt 5.7.0. But you should use .dll from the same version that was used for app compilation (5.6.1). It seems that it couldn't load plugin due to a version mismatch.

Upvotes: 0

Jeremy Friesner
Jeremy Friesner

Reputation: 73279

Sounds like your program's directory structure isn't quite correct. For a Windows Qt5 app, you should have a folder named "platforms" in the same directory as your .exe file, and inside that platforms folder should be the file qwindows.dll

Upvotes: 6

Related Questions