简体   繁体   English

如何解决Windows平台错误

[英]How to solve windows platform error

I make Windows application. 我制作Windows应用程序。 When I run it on my local computer with QT installation - everything is OK. 当我在装有QT的本地计算机上运行它时,一切正常。

But when I run it on another W10 PC or W28R2 server, I get known error. 但是,当我在另一台W10 PC或W28R2服务器上运行它时,会出现已知错误。

This application failed to start because it could not find or load the Qt platform plugin "Windows" Available platform plugins are: "windows" 此应用程序无法启动,因为无法找到或加载Qt平台插件“ Windows”。可用的平台插件为:“ windows”

I read all threads about this, but no find solution. 我阅读了有关此内容的所有主题,但没有找到解决方案。

My failed steps 我失败的步骤

  1. copy libEGL.dll into the myapp dir 将libEGL.dll复制到myapp目录中
  2. copy libEGLSv2.dll into the myapp dir 将libEGLSv2.dll复制到myapp目录中
  3. insert qwindows.dll into the myapp dir 将qwindows.dll插入myapp目录
  4. insert all dlls :-) into the myapp dir 将所有dll :-)插入myapp目录
  5. create QT_QPA_PLATFORM_PLUGIN_PATH variable in the project settings 在项目设置中创建QT_QPA_PLATFORM_PLUGIN_PATH变量
  6. run myapp with -platform and -platformpluginpath parametters 使用-platform和-platformpluginpath参数运行myapp
  7. use qt.conf file with QT_QPA_PLATFORM_PLUGIN_PATH parameter 使用带有QT_QPA_PLATFORM_PLUGIN_PATH参数的qt.conf文件

Interesting is, that when I rename " MYPATH\\Qt\\5.6\\msvc2015_64\\plugins\\platforms " directory from " platforms " to " platformsX ", application on my local computer also begins crash. 有意思的是,当我重新命名“mypath中\\ Qt的\\ 5.6 \\ msvc2015_64 \\插件\\平台 ”,从“ 平台 ”目录“platformsX”,我的本地计算机上的应用也开始崩溃。

It looks like a poorly filled global variable, but nothing works for me. 它看起来像一个填充不良的全局变量,但是对我没有任何作用。

This sloution was marked as duplicate with "Qt5 Static Build yields Failed to load platform plugin "windows"". 该记录被标记为“ Qt5 Static Build yields无法加载平台插件“ windows””重复。 But here missing windeployqt.exe myapp.exe --dir myapp_deps I write that thread and apply all advices, but still had the same problem. 但是在这里缺少windeployqt.exe myapp.exe --dir myapp_deps我编写了该线程并应用了所有建议,但仍然存在相同的问题。

By default Qt looks for its plugins in the application directory, but you must keep the plugin subdirectories as well. 默认情况下,Qt在应用程序目录中查找其插件,但是您也必须保留插件子目录。

In your case just copy qwindows.dll into myapp\\platforms dir so your app can find the plugin. 就您而言,只需将qwindows.dll复制到myapp\\platforms目录中,以便您的应用可以找到该插件。

Better yet, use the windeployqt.exe app bundled with your Qt installation and it will copy all the required Qt libraries and plugins. 更好的是,使用Qt安装附带的windeployqt.exe应用程序,它将复制所有必需的Qt库和插件。

For example i use the following as part of my deployment script: 例如,我将以下内容用作部署脚本的一部分:

windeployqt.exe myapp.exe --dir myapp_deps

This will copy all the required Qt libraries, plugins and VC++ redistributables (if you have VCINSTALLDIR/VSINSTALLDIR env correctly configured) to the myapp_deps directory. 这会将所有必需的Qt库,插件和VC ++可再发行文件(如果正确配置了VCINSTALLDIR / VSINSTALLDIR env)复制到myapp_deps目录。 (Note: if you omit the --dir argument then the command will copy all the dependencies to the current directory where myapp.exe resides). (注意:如果省略--dir参数,则该命令会将所有依赖项复制到myapp.exe所在的当前目录中)。

After this if you put myapp.exe into myapp_deps and relocate the folder to another PC without Qt installed then myapp.exe will run. 此后,如果将myapp.exe放入myapp_deps并将文件夹重新定位到未安装Qt的另一台PC,则myapp.exe将运行。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM