Application failed to start because it could not f

2019-01-01 07:45发布

I have looked through all of the questions that appear to be related on stack overflow, and none of the solutions seem to help me.

I am building a Qt application with this setup:

  • Windows 7 Professional x64
  • Visual Studio 2012
  • Qt 5.2.0 built with configure -developer-build -debug-and-release -opensource -nomake examples -nomake tests -platform win32-msvc2012 -no-opengl
  • Project uses QtSingleApplication (qt-solutions)
  • Application is a 32 bit application
  • qmake run with the following: -makefile -spec win32-msvc2012
  • .pri uses QMAKE_CXX += /D_USING_V110_SDK71_

I can build and run my program fine on my development machine (noted above); I can also install and run the package from Program Files directory on dev machine.

When I install and run on a Windows Vista machine (multiple machines)

  • VC++ redist 2012 11.0.61030.0 installed
  • VC++ redist 2010 10.0.40219 installed
  • plus 2005, 2008 versions of redist

(also fails on a clean install of Windows 7)

I get:

Application failed to start because it could not find or load the QT platform plugin "windows"

So I followed the instructions and added a .platforms/ directory, and added qwindows.dll (also added qminimal.dll and qoffscreen.dll); I also added libEGL.dll, libGLESv2.dll (even though I shouldn't need them I don't think)

Once I added qoffscreen.dll I now get the additional message: Available platform plugins are: offscreen

If I run through Dependency Walker I get this error listed:

GetProcAddress(0x76CA0000 [KERNEL32.DLL], "GetCurrentPackageId") called from "MSVCR110.DLL" at address 0x6AC6FDFA and returned NULL. Error: The specified procedure could not be found (127).

and then further down get the:

GetProcAddress(0x745A0000 [UXTHEME.DLL], "BufferedPaintUnInit") called from "COMCTL32.DLL" at address 0x745FFBF8 and returned 0x745AE18C.
This application failed to start because it could not find or load the Qt platform plugin "windows".

Available platform plugins are: offscreen.

Reinstalling the application may fix this problem.

Any ideas how to fix this dll issue?

12条回答
人间绝色
2楼-- · 2019-01-01 07:51

The error is caused because the program can't find qwindows.dll

qwindows.dll has to be in a folder named platforms so that the path from your executable to the dll is platforms/qwindows.dll

Whereas this wasn't enough in my case. I had also to add following line at the beginning of my main()

QCoreApplication::addLibraryPath("./");

Then everything worked.

查看更多
浪荡孟婆
3楼-- · 2019-01-01 07:53

It's missing qwindows.dll, which normally should be in platforms, unless you add:

QCoreApplication::addLibraryPath("<yourpath>");

If you don't do this btw, and put your qwindows.dll somewhere else, Qt will search your PATH for the DLL, which may take a LOT of time (10s - several minutes)!

查看更多
伤终究还是伤i
4楼-- · 2019-01-01 07:54

I got the same issue: 1. it can run in VS2010; 2. it can run in a folder with files as: app.exe \platforms\qwindows.dll ...

  1. but it failed to load qwindows on a clean machine with same OS as the developing one.

Solved simply by move the platform folder to plugins: app.exe plugins\platforms\qwindows.dll


plus: qwindows.dll can be renamed as any you like as it is queried by an plugin interafce: qt_plugin_query_metadata()

查看更多
无色无味的生活
5楼-- · 2019-01-01 08:03

I had the same issue "Application failed to start because it could not find or load the QT platform plugin "windows" I fixed this by copying below files to the app.exe (my app executable) folder,

Qt5Core.dll, Qt5Gui.dll, Qt5Widgets.dll and a "platforms" directory with qminimal.dll, qoffscreen.dll, qwindows.dll.

enter image description here

enter image description here

I hope this will help someone

查看更多
有味是清欢
6楼-- · 2019-01-01 08:05

I fixed this by placing qt.conf in my application's exe folder:

[Paths]
Prefix=C:/Qt/Qt5.11.2/5.11.2/msvc2017

Where:

  1. I have installed a custom Qt kit in C:\Qt\Qt5.11.2\5.11.2\msvc2017
  2. qt.conf informs the app where the custom kit via the Prefix property. Note use forward slashes not backslashes (!)
  3. And, optionally, the Qt kit's bin folder is included in my PATH environment variable

Defining Prefix in your qt.conf file allows it to find the qwindows.dll platform plugin when your app starts.

查看更多
回忆,回不去的记忆
7楼-- · 2019-01-01 08:07

I got this issue and how I solved it:

  1. Used dependency walker(http://www.dependencywalker.com/) to see the exact path of the dlls needed. Try it because both QtCreator and QT framework both have the same dlls and you must pinpoint the exact ones used. I copied all dlls needed in the same folder as the app.

  2. I have copied the folder platforms from QT framework /plugins and copied it in the same folder as the app. Now the app comtained also plugin/platform/ folder with all its dlls

  3. And the most important step in my case is to create a file named qt.conf in the same folder as the app . This file should contain the path to the plugins. My qt.conf file contains:

    [Paths]
    Libraries=../lib/qtcreator
    Plugins=plugins
    Imports=imports
    Qml2Imports=qml

查看更多
登录 后发表回答