C++ Qt5 静态构建产生无法加载平台插件“windows”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16773789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Qt5 Static Build yields Failed to load platform plugin "windows"
提问by Dave
I am writing a Qt application on Windows using Visual Studio 2012.
Using the Qt Add-in and a custom built staticdistribution 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:
我正在使用Visual Studio 2012在 Windows 上编写 Qt 应用程序。使用 Qt 插件和自定义构建的Qt 5.0.2静态发行版。每当我运行应用程序时,我都会遇到可怕的错误。我在链接器输入中添加了以下内容:"Failed to load platform plugin windows"
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?
起初我想也许我应该将“qwindowsd.lib”添加到该列表中,但这并没有解决问题。我需要做什么才能使我的应用程序运行?
采纳答案by Dave
回答by adler
For dynamic build only: Make sure you move the qwindows.dll to the following directory:
仅用于动态构建:确保将 qwindows.dll 移动到以下目录:
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.
请注意,缺少插件目录!您将 QT_BASE/.../plugins/* 中所有需要的文件夹直接与您的二进制文件放在一起。顺便说一句:我不需要 libEGL.dll,但我的应用程序几乎没有 GUI。
My source: http://qt-project.org/forums/viewthread/27056/#122588
回答by dagur
I had the same error with MinGW version of Qt (not static): "Failed to load platform plugin windows".
我在使用 Qt 的 MinGW 版本(非静态)时遇到了同样的错误:“无法加载平台插件窗口”。
The solution for me was to add the DLLs libEGL.dll
and libEGLd.dll
.
我的解决方案是添加 DLLlibEGL.dll
和libEGLd.dll
.
回答by G.Vanem
You could also make an environment variable:
您还可以创建一个环境变量:
QT_QPA_PLATFORM_PLUGIN_PATH=<QT_BASE>\plugins\platforms
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
在我的情况下变成:
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!?).
从而避免qwindows.dll
在开发过程中安装/复制(以节省磁盘空间!?)。
This solution was also mentioned on GitHuband here.
EDIT: Sorry, this is not effective in a static build. But I'll leave my Ahere.
编辑:抱歉,这在静态构建中无效。但我会把我的A留在这里。
回答by Yves Lange
Ok I had similar issue.
好的,我有类似的问题。
I found out that QT 5.2+ has windeployq.exe
我发现 QT 5.2+ 有 windeployq.exe
QT_DIRECTORY\5.2...\bin\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 !
将它与您的项目目录(应用程序的 .exe 所在的目录)一起使用。瞧!自动链接所有内容并准备部署!
It will get the DLLs, Plugins etc... automatically !
它将自动获取 DLL、插件等...!
回答by darrenp
An alternative is to copy the qtbase/plugins/platforms
directory into the Debug/Release directories leaving just qwindowsd.dll
or qwindows.dll
as appropriate.
另一种方法是将qtbase/plugins/platforms
目录复制到 Debug/Release 目录中,仅保留qwindowsd.dll
或qwindows.dll
酌情保留。
回答by Zerizer hichem
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
解决方案是,如果您使用 anaconda 和 python 使用 qt 设计器制作 gui,则转到 anaconda,pkgs,qt.xxx,library,plugins ,然后将平台文件夹复制到包含您的 program.exe 的构建文件夹中
回答by nairboon
Starting with QT 5.9+ Qt5PlatformSupport.libis no longer available and has been splitinto different libraries. To create a static build under windows one needs to link the following additional libraries:
与QT 5.9+开始Qt5PlatformSupport.lib不再可用,并已分裂成不同的库。要在 Windows 下创建静态构建,需要链接以下附加库:
Qt5FontDatabaseSupport.lib
Qt5EventDispatcherSupport.lib
Qt5ThemeSupport.lib
Qt5PlatformCompositorSupport.lib
Qt5AccessibilitySupport.lib
Qt5WindowsUiAutomationSupport.lib
qwindows.lib
and load the windows plugin statically:
并静态加载 Windows 插件:
#include <QtPlugin>
Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin);
回答by Jum
I had the same error with VS2015 and the version of Qt 5.9.3
我在 VS2015 和 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
我通过用 Qt 目录中的相同 DLL 替换 Qt5Cored.dll 和 Qt5Core.dll(我的应用程序的 exe 所在的位置)解决了该错误
回答by user2793449
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.
我正是这个问题。解决方法是在Debug输出中检查Qt。该窗口会告诉您它加载的所有 DLL。这些是您的发行版 exe 文件夹中可能需要的那些。