exo exo - 1 year ago 111
C++ Question

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download