Reputation: 1249
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:
configure -developer-build -debug-and-release -opensource -nomake examples -nomake tests -platform win32-msvc2012 -no-opengl
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)
(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?
Upvotes: 34
Views: 85322
Reputation: 9525
I'm seeing this question in various forms getting verbose non-answers, complicated answers, etc., across StackOverflow, Microsoft forums, and Qt forums. Just to clear through everything ... the relevant text in the Qt documentation is this:
All Qt GUI applications require a plugin that implements the Qt Platform Abstraction (QPA) layer in Qt. For Windows, the name of the platform plugin is qwindows.dll. This file must be located within a specific subdirectory (by default, platforms) under your distribution directory. [...]
The search paths for Qt plugins are relative to the location of the QtCore library and no further steps are required to ensure plugins are found after installing the application on the target machine.
So relative to where your executable is finding QtCore.dll you need to have a directory called "plugins" with contents that Qt expects. So a minimal Windows Qt installation looks like this:
+ <your installation dir>
o <your .exe>
o Qt6Core.dll
o Qt6Gui.dll
o Qt6Widgets.dll
+ plugins
+ platforms
qwindows.dll
The documentation is less than clear about the necessity of the "platforms" directory but you can see this is the way they lay out the "plugins" directory in their distribution.
Upvotes: 0
Reputation: 1439
You need to add environmental variable QT_QPA_PLATFORM_PLUGIN_PATH
to the system which points to the platforms directory in QT plugins. In my case, I was using Anaconda and PySide2. Therefore my directory path was C:\ProgramData\Anaconda3\envs\cv\Lib\site-packages\PySide2\plugins
. This fixes the issue for every QT project. Otherwise, you have copy platforms directory to every QT project.
Upvotes: 0
Reputation: 25871
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:
C:\Qt\Qt5.11.2\5.11.2\msvc2017
qt.conf
informs the app where the custom kit via the Prefix
property. Note use forward slashes not backslashes (!)PATH
environment variableDefining Prefix
in your qt.conf
file allows it to find the qwindows.dll
platform plugin when your app starts.
Upvotes: 1
Reputation: 61
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.
I hope this will help someone
Upvotes: 5
Reputation: 9113
For me, I needed to set QT_QPA_PLATFORM_PLUGIN_PATH
to the platforms directory and then it worked.
For what it's worth, this solution was also mentioned on GitHub.
Upvotes: 3
Reputation: 1
Tried all the above - turned out for me it was simply because I didn't have the main Qt
dlls in the apps
folder
Upvotes: 0
Reputation: 571
For the people who have this problem in the future - I have a dirty little hack, worked for me. Try at your own risk.
Follow all the steps in Initial deployment (Quick and dirty) [http://wiki.qt.io/Deploy_an_Application_on_Windows]
Now for the hack -
You can close the .exe file now. To check whether it is deploying okay, go into the folder where you installed it, say C:/Qt and rename it to C:/NotQt (basically make Qt invisible to the system). If it works now, it will deploy on other systems more often than not.
Upvotes: 2
Reputation: 6776
The application is able to run on the host system, since the Qt bin
path is in the system PATH
variable.
There is a standard Qt tool for deployment of Qt applications on Windows windeployqt
to be able to run the application on target machines that do not have Qt installed.
That tool takes care about Qt DLL dependencies, makes a copy of platforms\qwindows.dll
and also it makes a copy of libraries that you cannot detect with the Dependency Walker, since image plugins and some other DLLs are loaded at runtime.
You do not even need to have your Qt bin
folder in your environment PATH
. The simplest deployment:
exe
binary to a new foldercmd
console in that folderwindeployqt
using the full path (if it is not in the system PATH
) and provide your executable, for example:
c:\Qt\Qt5.2.1\5.2.1\msvc2010_opengl\bin\windeployqt.exe application.exe
As a result you have in that folder all needed Qt DLLs to run the application.
The tool windeployqt
has various options. It can also take care about deployment of qml
related files.
Of course you can have also issues with MSVC redistributables, but those should be deployed separately and installed once per system.
Only some 3rd party libraries should be copied manually if they are used, for example OpenSSL.
Upvotes: 11
Reputation: 150
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)!
Upvotes: 1
Reputation: 96537
Note this issue can also be caused if the search path for qwindows.dll
that is encoded in your app includes the path where you installed Qt. Consider the following scenario:
c:\Qt\...
qwindows.dll
in a subdirectory.The result is this error, because the qwindows.dll
in c:\Qt\...
is found before the one in its local directory and it is incompatible with it. Very annoying.
A solution is to place a file qt.conf
in the same directory as your exe file. I don't know how to avoid this. If you used the tool windeployqt.exe
to deploy your app, so you have a subdirectory called platforms
, then this is sufficient:
[Paths]
Plugins=.
Upvotes: 4
Reputation: 2215
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.
Upvotes: 28
Reputation: 11
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 ...
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()
Upvotes: 1
Reputation: 894
I got this issue and how I solved it:
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.
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
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
Upvotes: 9
Reputation: 1249
Well I solved my issue, although I'm not sure what the difference is:
I copied every dll from my qt directory into both ./ and ./platforms of my application directory.
The application got past the error, but then crashed.
VERSION.dll was causing the crash (noted in dependency walker), so I removed it from both places.
The Application started up, so I systematically removed all unneeded dll's.
This got me back to the same state I had originally.
I then uninstalled my application and re-installed (with only the ./platforms/qwindows.dll file remaining), application works correctly.
So all I can assume is that I had an incorrect version of qwindows.dll in the platforms directory.
Upvotes: 1