简体   繁体   English

Qt5 静态构建产生无法加载平台插件“windows”

[英]Qt5 Static Build yields Failed to load platform plugin "windows"

I am writing a Qt application on Windows using Visual Studio 2012 .我正在使用Visual Studio 2012在 Windows 上编写 Qt 应用程序。 Using the Qt Add-in and a custom built static distribution of Qt 5.0.2 .使用 Qt 插件和自定义构建的Qt 5.0.2静态发行版。 I am running into the dreaded "Failed to load platform plugin windows" error whenever I run the application.每当我运行应用程序时,我都会遇到可怕的"Failed to load platform plugin windows"错误。 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.起初我想也许我应该将“qwindowsd.lib”添加到该列表中,但这并没有解决问题。 What do I need to do in order to make my application run?我需要做什么才能使我的应用程序运行?

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.您将 QT_BASE/.../plugins/* 中所有需要的文件夹直接与您的二进制文件放在一起。 BTW: I did not need libEGL.dll, but my application almost has no GUI.顺便说一句:我不需要 libEGL.dll,但我的应用程序几乎没有 GUI。

My source: http://qt-project.org/forums/viewthread/27056/#122588我的来源: http : //qt-project.org/forums/viewthread/27056/#122588

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);

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 .我的解决方案是添加 DLL libEGL.dlllibEGLd.dll

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在我的情况下变成: 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 GitHub and here . GitHub此处也提到此解决方案。

EDIT: Sorry, this is not effective in a static build.编辑:抱歉,这在静态构建中无效。 But I'll leave my A here.但我会把我的A留在这里。

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).将它与您的项目目录(应用程序的 .exe 所在的目录)一起使用。 And voilà !瞧! Automatically linked everything and ready to deploy !自动链接所有内容并准备部署!

It will get the DLLs, Plugins etc... automatically !它将自动获取 DLL、插件等...!

另一种方法是将qtbase/plugins/platforms目录复制到 Debug/Release 目录中,根据需要仅qwindowsd.dllqwindows.dll

解决方案是,如果您使用 anaconda 和 python 使用 qt 设计器制作 gui,则转到 anaconda,pkgs,qt.xxx,library,plugins ,然后将平台文件夹复制到包含您的 program.exe 的构建文件夹中

Starting with QT 5.9+ Qt5PlatformSupport.lib is no longer available and has been split into different libraries.与QT 5.9+ Qt5PlatformSupport.lib开始,不再可用,并已分裂成不同的库。 To create a static build under windows one needs to link the following additional libraries:要在 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);

I exactly this probelm.我正是这个问题。 The solution is to check the Qt in Debug output.解决方法是在Debug输出中检查Qt。 That window tells you all the DLLs it loads.该窗口会告诉您它加载的所有 DLL。 These are the ones you may need in your distribution exe folder.这些是您的发行版 exe 文件夹中可能需要的那些。

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 所在的位置)解决了该错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Qt应用程序:无法加载平台插件“windows” - Qt application: Failed to load platform plugin “windows” Qt应用程序:无法加载平台插件“windows”。 可用的平台是: - Qt application: Failed to load platform plugin “windows”. Available platforms are: 该应用程序无法启动,因为无法在“”中找到或加载Qt平台插件“ xcb”。 AND找不到/ usr / lib / qt5 - This application failed to start because it could not find or load the Qt platform plugin “xcb” in “”. AND cannot find /usr/lib/qt5 无法找到或加载Qt平台插件“windows” - Could not find or load the Qt platform plugin “windows” 无法加载Qt平台插件Windows - Can not load the qt platform plugin windows 找不到 Qt 平台插件 xcb,在 Qt5 上从 Linux 上的源构建 - Could not find the Qt platform plugin xcb, on Qt5 build from source on Linux 应用程序无法启动,因为它无法找到或加载QT平台插件“windows” - Application failed to start because it could not find or load the QT platform plugin “windows” 此应用程序无法启动,因为它无法找到或加载Qt平台插件“windows”错误消息 - This application failed to start because it could not find or load the Qt platform plugin “windows” error message 此应用程序无法启动,因为无法找到或加载Qt平台插件“ Windows” - This application failed to start because it could not find or load the Qt platform plugin “windows” 静态链接的应用程序与Qt给出错误:无法加载平台插件“窗口” - Statically linked app with Qt gives error: Failed to load platform plugin “windows”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM