Qt5 Static Build yields Failed to load platform plugin "windows"

81,589

Solution 1

I solved it. Thanks to this I was able to get everything to work. I added the following libraries:

opengl32.lib
Qt5PlatformSupport.lib
qwindows.lib

I also added the following to my code:

#include <QtPlugin>
Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin);

Solution 2

For dynamic build only: Make sure you move the qwindows.dll to the following directory:

yourapp.exe
Qt5Core.dll
...
platforms/qwindows.dll
...

Note that the plugins directory is missing! You put all the needed folders from QT_BASE/.../plugins/* directly together with your binaries. BTW: I did not need libEGL.dll, but my application almost has no GUI.

My source: http://qt-project.org/forums/viewthread/27056/#122588

Solution 3

I had the same error with MinGW version of Qt (not static): "Failed to load platform plugin windows".

The solution for me was to add the DLLs libEGL.dll and libEGLd.dll.

Solution 4

You could also make an environment variable:

QT_QPA_PLATFORM_PLUGIN_PATH=<QT_BASE>\plugins\platforms

which in my case becomes: QT_QPA_PLATFORM_PLUGIN_PATH=f:\Qt\5\5.4\msvc2013_opengl\plugins\platforms

Thus avoiding installing/copying qwindows.dll during development (to save disk-space!?).

This solution was also mentioned on GitHub and here.

EDIT: Sorry, this is not effective in a static build. But I'll leave my A here.

Solution 5

Ok I had similar issue.

I found out that QT 5.2+ has windeployq.exe

QT_DIRECTORY\5.2...\bin\windeployq.exe

Use it with the directory of your project (where the .exe of your application is). And voilà ! Automatically linked everything and ready to deploy !

It will get the DLLs, Plugins etc... automatically !

Share:
81,589
Dave
Author by

Dave

I'm a software developer living in Toronto, Canada. I earned a bachelor's degree in computer science from Carleton University and am currently working at StackAdapt.

Updated on January 12, 2020

Comments

  • Dave
    Dave over 4 years

    I am writing a Qt application on Windows using Visual Studio 2012. Using the Qt Add-in and a custom built static distribution of Qt 5.0.2. I am running into the dreaded "Failed to load platform plugin windows" error whenever I run the application. I have added the following to the linker input:

    imm32.lib
    winmm.lib
    Ws2_32.lib
    qtmaind.lib
    Qt5Cored.lib
    Qt5Guid.lib
    Qt5Widgetsd.lib
    

    At first I thought that maybe I should add "qwindowsd.lib" to that list as well however that did not fix the problem. What do I need to do in order to make my application run?