C++ Qt 5.1.1:应用程序无法启动,因为平台插件“windows”缺失
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20495620/
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
Qt 5.1.1: Application failed to start because platform plugin "windows" is missing
提问by Anonymous
Edit:Some people started to mark my question as a duplicate. Do not forget that many similar questions existed when I asked this one (see e.g. the list below). However, none of these answers solved my problem. After a long search I found a commentwhich had been ignored by all users pointing to the missing lib. Now, many months later, the comment has been changed to an answer. However, when I answered this question by msyself I intended to help other people by directly providing the solution. This should not be forgotten and so far my answer helped a lot of people. Therefore my question is definitely not a duplicate. By the way: The accepted answer within the provided link on top does not solve the problem!
编辑:有些人开始将我的问题标记为重复。不要忘记当我问这个问题时存在许多类似的问题(参见例如下面的列表)。但是,这些答案都没有解决我的问题。经过长时间的搜索,我发现了一条评论,该评论已被所有用户忽略,指向丢失的库。现在,几个月后,评论已更改为答案。但是,当我自己回答这个问题时,我打算通过直接提供解决方案来帮助其他人。这不应该被遗忘,到目前为止,我的回答帮助了很多人。因此,我的问题绝对不是重复的。 顺便说一句:顶部提供的链接中接受的答案并不能解决问题!
Yes, i used the search:
是的,我使用了搜索:
Failed to load platform plugin "windows". Available platforms are : Error
Deploying Qt C++ Application from Visual Studio qwindows.dll error
从 Visual Studio qwindows.dll 错误部署 Qt C++ 应用程序
failed to load platform plugin "windows" Available platforms are: windows, minimal
无法加载平台插件“windows”可用平台是:windows,minimal
However, in my case the problem still persists. I am using Qt 5.1.1 with Visual Studio 2012 and developed my Application on Windows 7 with Qt Creator 2.8.1. Application is compiled in "Release"-mode and can be executed if directly started with Qt Creator.
但是,就我而言,问题仍然存在。我在 Visual Studio 2012 中使用 Qt 5.1.1,并在 Windows 7 上使用 Qt Creator 2.8.1 开发了我的应用程序。应用程序以“发布”模式编译,如果直接使用 Qt Creator 启动,则可以执行。
However, when starting from the "release"-Folder, i get the following message:
但是,从“发布”文件夹开始时,我收到以下消息:
This application failed to start because it could not find or load the Qt platform plugin "windows". Available platform plugins are: minimal, offscreen, windows.
此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“windows”。可用的平台插件有:minimal、offscreen、windows。
Folder structure looks like this:
文件夹结构如下所示:
release
+ gui.exe
+ icudt51.dll
+ icuin51.dll
+ icuuc51.dll
+ libGLESv2.dll
+ Qt5Core.dll
+ Qt5Gui.dll
+ Qt5Widgets.dll
+ platforms
Platforms is the folder directly copied from Qt\Qt5.1.1\5.1.1\msvc2012\plugins\platformsincluding e.g. qwindows.dll. Does not matter if I rename it to "platform" as some other users did. Qt is still not finding the "platform plugin windows", where is my mistake?
Platforms 是直接从Qt\Qt5.1.1\5.1.1\msvc2012\plugins\platforms复制的文件夹,包括 qwindows.dll。如果我像其他一些用户那样将其重命名为“平台”,则无关紧要。Qt 仍然没有找到“平台插件窗口”,我的错误在哪里?
采纳答案by Anonymous
Okay, as posted here https://stackoverflow.com/a/17271172/1458552without much attention by other users:
好的,正如这里发布的https://stackoverflow.com/a/17271172/1458552其他用户没有太多关注:
The libEGL.dllwas missing! Even though this has not been reported when trying to start the application (all other *.dlls such as Qt5Gui.dll had been reported).
该libEGL.dll失踪了!即使在尝试启动应用程序时尚未报告此问题(已报告所有其他 *.dll,例如 Qt5Gui.dll)。
回答by Brandon
I created a platforms directory next to my exe location and put qwindows.dll inside, but I still received the "Failed to load platform plugin "windows". Available platforms are: windows" error.
我在我的 exe 位置旁边创建了一个平台目录并将 qwindows.dll 放入其中,但我仍然收到“无法加载平台插件“windows”。可用平台为:windows”错误。
I had copied qwindows.dll from C:\Qt\Qt5.1.1\Tools\QtCreator\bin\plugins\platforms, which is not the right location. I looked at the debug log from running in Qt Creator and found that my app was looking in C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\platforms when it ran in the debugger.
我从 C:\Qt\Qt5.1.1\Tools\QtCreator\bin\plugins\platforms 复制了 qwindows.dll,这不是正确的位置。我查看了在 Qt Creator 中运行的调试日志,发现我的应用程序在调试器中运行时正在 C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\platforms 中查找。
When I copied from C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\platforms, everything worked fine.
当我从 C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\platforms 复制时,一切正常。
回答by CrippledTable
The release is likely missing a library/plugin or the library is in the wrong directory and or from the wrong directory.
该版本可能缺少库/插件,或者库位于错误的目录和/或来自错误的目录。
Qt intended answer: Use windeployqt. see last paragraph for explanation
Qt 预期答案:使用windeployqt。见最后一段的解释
Manual answer:
手动回答:
Create a folder named "platforms" in the same directory as your application.exe file. Copy and paste the qwindows.dll, found in the /bin of whichever compiler you used to release your application, into the "platforms" folder. Like magic it works. If the .dll is not there check plugins/platforms/ ( with plugins/ being in the same directory as bin/ ) <-- PfunnyGuy's comment.
在与 application.exe 文件相同的目录中创建一个名为“platforms”的文件夹。将在用于发布应用程序的任何编译器的 /bin 中找到的 qwindows.dll 复制并粘贴到“平台”文件夹中。就像魔法一样有效。如果 .dll 不存在,请检查 plugins/platforms/ ( plugins/ 与 bin/ 位于同一目录中)<-- PfunnyGuy 的评论。
It seems like a common issue is that the .dll was taken from the wrong compiler bin. Be sure to copy your the qwindows.dll from the same compiler as the one used to release your app.
似乎一个常见问题是 .dll 是从错误的编译器 bin 中获取的。请务必从与用于发布应用程序的编译器相同的编译器复制您的 qwindows.dll。
Qt comes with platform console applications that will add all dependencies (including ones like qwindows.dll and libEGL.dll) into the folder of your deployed executable. This is the intended way to deploy your application, so you do not miss any libraries (which is the main issue with all of these answers). The application for windows is called windeployqt. There is likely a deployment console app for each OS.
Qt 带有平台控制台应用程序,这些应用程序会将所有依赖项(包括 qwindows.dll 和 libEGL.dll 之类的依赖项)添加到您部署的可执行文件的文件夹中。这是部署应用程序的预期方式,因此您不会错过任何库(这是所有这些答案的主要问题)。Windows 应用程序称为windeployqt。每个操作系统可能都有一个部署控制台应用程序。
回答by Jim G.
回答by Joel
I ran into this and none of the answers I could find fixed it for me.
My colleauge has Qt (5.6.0) installed on his machine at:
C:\Qt\Qt5.6.0\5.6\msvc2015\plugins
I have Qt (5.6.2) installed in the same location.
I learned from this post: http://www.tripleboot.org/?p=536, that the Qt5Core.dll has a location to the plugins written to it when Qt is first installed.
Since my colleague's and my Qt directories were the same, but different version of Qt were installed, a different qwindows.dll file is needed. When I ran an exe deployed by him, it would use my C:\Qt\Qt5.6.0\5.6\msvc2015\plugins\platforms\qwindows.dll file instead of the one located next to the executable in the .\platforms subfolder.
我遇到了这个问题,但我找不到任何答案可以为我解决这个问题。
我的同事在他的机器上安装了 Qt(5.6.0):C:\Qt\Qt5.6.0\5.6\msvc2015\plugins
我在同一位置安装了 Qt(5.6.2)。
我从这篇文章中了解到:http: //www.tripleboot.org/?p=536 ,Qt5Core.dll 在 Qt 首次安装时有一个写入插件的位置。由于我同事和我的 Qt 目录相同,但安装了不同版本的 Qt,因此需要不同的 qwindows.dll 文件。当我运行他部署的 exe 时,它将使用我的 C:\Qt\Qt5.6.0\5.6\msvc2015\plugins\platforms\qwindows.dll 文件,而不是位于 .\platforms 子文件夹中可执行文件旁边的文件。
To get around this, I added the following line of code to the application which seems to force it to look next to the exe for the 'platforms' subfolder before it looks at the path in the Qt5Core.dll.
为了解决这个问题,我在应用程序中添加了以下代码行,这似乎迫使它在查看 Qt5Core.dll 中的路径之前,在“平台”子文件夹的 exe 旁边查找。
QCoreApplication::addLibraryPath(".");
I added the above line to the main method before the QApplication call like this:
我在 QApplication 调用之前将上面的行添加到 main 方法中,如下所示:
int main( int argc, char *argv[] )
{
QCoreApplication::addLibraryPath(".");
QApplication app( argc, argv );
...
return app.exec();
}
回答by KunMing Xie
create dir platforms
and copy qwindows.dll
to it, platforms
and app.exe
are in the same dir
创建目录platforms
并复制qwindows.dll
到它,platforms
并且app.exe
在同一个目录中
cd app_dir
mkdir platforms
xcopy qwindows.dll platforms\qwindows.dll
cd app_dir
mkdir platforms
xcopy qwindows.dll platforms\qwindows.dll
Folder structure
+ app.exe
+ platforms\qwindows.dll
文件夹结构
+ app.exe
+ platforms\qwindows.dll
回答by Peter Quiring
I found another solution. Create qt.conf in the app folder as such:
我找到了另一个解决方案。在 app 文件夹中创建 qt.conf 如下:
[Paths]
Prefix = .
And then copy the plugins folder into the app folder and it works for me.
然后将 plugins 文件夹复制到 app 文件夹中,它对我有用。
回答by Jacob Robbins
Most of these answers contain good (correct) info, but in my case, there was still something missing.
这些答案中的大多数都包含好的(正确的)信息,但就我而言,仍然缺少一些东西。
My app is built as a library (dll) and called by a non-Qt application. I used windeployqt.exe
to set up the Qt dlls, platforms, plugins, etc. in the install directory, but it still couldn't find the platform. After some experimentation, I realized the application's working directory was set to a different folder. So, I grabbed the directory in which the dll "lived" using GetModuleHandleExA
and added that directory to the Qt library path at runtime using
我的应用程序构建为库 (dll) 并由非 Qt 应用程序调用。我windeployqt.exe
以前在安装目录下设置了Qt dll、平台、插件等,但是还是找不到平台。经过一些实验,我意识到应用程序的工作目录被设置为不同的文件夹。因此,我使用了 dll“存在”的GetModuleHandleExA
目录,并在运行时将该目录添加到 Qt 库路径中
QCoreApplication::addLibraryPath(<result of GetModuleHandleExA>);
This worked for me.
这对我有用。
回答by Ire
I had the same problem and solved it by applying several things. The first, if it is a program that you did with Qt.
我遇到了同样的问题,并通过应用几件事来解决它。第一个,如果它是你用 Qt 做的程序。
In the folder (in my case) of "C: \ Qt \ Qt5.10.0 \ 5.10.0 \ msvc2017_64 \ plugins" you find other folders, one of them is "platforms". That "platforms" folder is going to be copied next to your .exe executable. Now, if you get the error 0xc000007d is that you did not copy the version that was, since it can be 32bits or 64.
在“C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\plugins”的文件夹(在我的情况下)中,您可以找到其他文件夹,其中之一是“平台”。该“平台”文件夹将被复制到您的 .exe 可执行文件旁边。现在,如果您收到错误 0xc000007d 是因为您没有复制原来的版本,因为它可以是 32 位或 64 位。
If you continue with the errors is that you lack more libraries. With the "Dependency Walker" program you can detect some of the missing folders. Surely it will indicate to you that you need an NVIDIA .dll, and it tells you the location.
如果您继续出现错误,则说明您缺少更多库。使用“Dependency Walker”程序,您可以检测一些丢失的文件夹。它肯定会向您表明您需要一个 NVIDIA .dll,并告诉您位置。
Another way, instead of using "Dependency Walker" is to copy all the .dll from your "C: \ Windows \ System32" folder next to your executable file. Execute your .exe and if everything loads well, so you do not have space occupied in dll libraries that you do not need or use, use the .exe program with all your options and without closing the .exe you do is erase all the .dll that you just copied next to the .exe, so if those .dll are being used by your program, the system will not let you erase, only removing those that are not necessary.
另一种方法是从可执行文件旁边的“C:\Windows\System32”文件夹中复制所有 .dll,而不是使用“Dependency Walker”。执行您的 .exe,如果一切正常,那么您不需要或使用的 dll 库中没有占用空间,请使用带有所有选项的 .exe 程序并且不关闭 .exe 您所做的就是擦除所有 .您刚刚复制到 .exe 旁边的 dll,因此如果您的程序正在使用这些 .dll,系统不会让您擦除,只会删除那些不需要的。
I hope this solution serves you.
我希望这个解决方案可以为您服务。
Remember that if your operating system is 64 bits, the libraries will be in the System32 folder, and if your operating system is 32 bits, they will also be in the System32 folder. This happens so that there are no compatibility problems with programs that are 32 bits in a 64-bit computer. The SysWOW64 folder contains the 32-bit files as a backup.
请记住,如果您的操作系统是 64 位,库将在 System32 文件夹中,如果您的操作系统是 32 位,它们也将在 System32 文件夹中。发生这种情况是为了使 64 位计算机中的 32 位程序不存在兼容性问题。SysWOW64 文件夹包含 32 位文件作为备份。
回答by Jann Poppinga
For me the solution was to correct the PATH
variable. It had Anaconda3\Library\bin as one of the first paths. This directory contains someQt libraries, but not all. Apparently, that is a problem. Moving C:\Programs\Qt\5.12.3\msvc2017_64\bin to the front of PATH
solved the problem for me.
对我来说,解决方案是纠正PATH
变量。它有 Anaconda3\Library\bin 作为第一条路径之一。该目录包含一些Qt 库,但不是全部。显然,这是一个问题。将 C:\Programs\Qt\5.12.3\msvc2017_64\bin 移到前面PATH
为我解决了问题。