Qt5 Static Build yields Failed to load platform pl

2019-01-01 15:46发布

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?

9条回答
与君花间醉酒
2楼-- · 2019-01-01 16:17

I had the same error with VS2015 and the version of Qt 5.9.3

I solved the error by replacing the Qt5Cored.dll and Qt5Core.dll(where the exe of my application) with the same DLLs in Qt directory

查看更多
高级女魔头
3楼-- · 2019-01-01 16:18

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.

查看更多
一个人的天荒地老
4楼-- · 2019-01-01 16:20

An alternative is to copy the qtbase/plugins/platforms directory into the Debug/Release directories leaving just qwindowsd.dll or qwindows.dll as appropriate.

查看更多
ら面具成の殇う
5楼-- · 2019-01-01 16:20

The solutions is,if you are using anaconda and python to make a gui using qt designer then go to anaconda,pkgs,qt.xxx,library,plugins ,then copy the platforms folder to your build folder wich contains your program.exe

查看更多
只若初见
6楼-- · 2019-01-01 16:26

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

查看更多
路过你的时光
7楼-- · 2019-01-01 16:26

I exactly this probelm. The solution is to check the Qt in Debug output. That window tells you all the DLLs it loads. These are the ones you may need in your distribution exe folder.

查看更多
登录 后发表回答