简体   繁体   中英

How to solve windows platform error

I make Windows application. When I run it on my local computer with QT installation - everything is OK.

But when I run it on another W10 PC or W28R2 server, I get known error.

This application failed to start because it could not find or load the Qt platform plugin "Windows" Available platform plugins are: "windows"

I read all threads about this, but no find solution.

My failed steps

  1. copy libEGL.dll into the myapp dir
  2. copy libEGLSv2.dll into the myapp dir
  3. insert qwindows.dll into the myapp dir
  4. insert all dlls :-) into the myapp dir
  5. create QT_QPA_PLATFORM_PLUGIN_PATH variable in the project settings
  6. run myapp with -platform and -platformpluginpath parametters
  7. use qt.conf file with QT_QPA_PLATFORM_PLUGIN_PATH parameter

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.

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"". But here missing windeployqt.exe myapp.exe --dir myapp_deps I write that thread and apply all advices, but still had the same problem.

By default Qt looks for its plugins in the application directory, but you must keep the plugin subdirectories as well.

In your case just copy qwindows.dll into myapp\\platforms dir so your app can find the plugin.

Better yet, use the windeployqt.exe app bundled with your Qt installation and it will copy all the required Qt libraries and plugins.

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. (Note: if you omit the --dir argument then the command will copy all the dependencies to the current directory where myapp.exe resides).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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