This application failed to start because it could not find or load the Qt platform plugin "windows" - c++

I tried making an executable file of my program but there are some errors which I did not understand or could not find solutions of. I used my .exe file onto another computer and there was an error. I made my program through QtCreator (v 5.1.1)with my Windows 7, 64-bit laptop. There was an error when I used it in 2 32-bit laptops.
The error message says:
This application failed to start because it could not find or load the Qt platform plugin "windows".
Available platform plugins are: minimal, offscreen, windows.
Reinstalling the application may fix the problem.
I already created a new folder called "platforms" containing "qminimal.dll", "qoffscreen.dll" and "qwindows.dll" in the same level of my .exe file. I also pasted in the same level the other DLLs that my program needs.

In Qt 5.2, there is a tool that can be used for deployment on Windows: windeployqt. It will be in the bin folder of your Qt installation. It greatly simplifies deployment, so if you don't mind downloading a newer Qt version, I'd highly recommend it. It may even work with an older Qt version, but I haven't tested it.

We had exact same problem with Qt5.3.
Problem arised when we've rebuilt the Qt to reduce dependencies (e.g. Qt5Positioning, Qt5Sensors).
Created dlls were copied to different directory (source for installation), but we forgot to copy also newly created platforms plugin dlls.
The problem was fixed by using all dlls from same Qt build (with same configuration).
Your problem is probably the same: mixing dlls from different Qt builds (e.g. different configuration, version,...).

Related

Cannot run Qt Creator GUI outside of Qt. "The application was unable to start correctly (0xc000007b)" error

I downloaded C++ code from GitHub to tag images for training an object detector using Machine Learning.
Within Qt Creator 4.2.1 Based on Qt 5.8.0 (MSVC 2015, 32bit), I was able to compile and run the code. Unfortunately, I was not able to run the .exe outside of Qt Creator.
Initially, I received an error that
"The program can't start because libgcc_s_dw2-1.dll is missing".
Thanks to
QT The program can't start because libgcc_s_dw2-1.dll is missing, that was fixed easily by adding
"QMAKE_LFLAGS += -static"
to the .pro file. Now, when I run it I get
"The application was unable to start correctly (0xc000007b). Click OK to close the application."
I was able to reproduce the error using the simple "Hello World" default project that appears when you create a Qt Widget Application. This led me to believe something was wrong with my installation.
Based on the advice of this article: https://stackoverflow.com/questions/12099117/32-bit-qt-application-on-win-7-x64-wont-run-but-runs-fine-from-qt-creator, I used Dependency Walker to identify possible causes. I expected to see only a few items that I can follow up on. Instead, I received a list of close to 100 missing .dll files. All the files started with
"API-MS-WIN ###.DLL" or "EXT-MS ###.DLL"
where ### represent some additional text characters, for example;
"API-MS-WIN-SHCORE-STREAM-WINRT-L1-1-0.DLL"
I'm attaching a sample output.
Another suggestion was to copy over
libwinpthread-1.dll, libstdc++-6.dll, libgcc_s_dw2-1.dll.
That did not work either.
My next move was to simply get the latest version of QT and wish for the best. I installed Qt Creator 4.8.1 Based on At 5.12.0 (MSVC 2015, 32 bit). This time, I could not even get the code to run in the IDE. I received 1000+ error messages!
Based on advice from several pages, I added
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
to the .pro file and it still would not compile.
Also, I verified that the application is being built as a 32bit application. I'm running on a 64 bit Windows 10 system.
If anyone would like to take a crack at it to see if they can create a working .exe, here is the link: github.com/clavicule/BBTag
Qt provides a tool to copy the necessary dlls to the folder of your executable.
The tools is called windeployqt.exe and comes with your Qt installation. For me it is located at C:\Qt\5.9.1\msvc2015_64\bin\windeployqt.exe. You will have to look at your installation path and probably the msvc_32 folder to find it.
Then you go to the folder with your executable in it, oben a command prompt or powershell and execute path\to\windeployqt.exe yourProgram.exe and it will automatically copy the necessary dll files to this folder. Afterwards you can run your program without issues.
The official documentation for the tool can be found here.
Alternative 1: While developing you could use QtCreator which automatically adds the paths to the dlls when running your program - make sure to include them if you deploy your program!
Alternative 2: Add the path to the necessary dlls to your PATH variable. This isn't recommended either, since everyone who gets your program would have to do the same to run it.
I figured it out! My installation of Anaconda (a Python distribution popular for data science and machine learning) is the culprit.
From: #remy-lebeau
The application was unable to start correctly (0xc000007b)
The error:
"The application was unable to start correctly (0xc000007b) ..."
is a good indicator that the 32-bit app tried to load a 64-bit DLL. At first, this did not make sense since I verified many times that I was using the 32 bit version of Qt.
It turns out that the installation of the 64 bit version of Anaconda also contained many Qt5 dlls used for the PyQt5 package. Since the path to this folder came before the path to my c:\Qt...\bin folder, it was used in the build instead of the actual 32 bit version installed with Qt. This was not obvious because I was unaware of PyQt5 so I had no idea that it came with Anaconda. A simple reordering of the path entries using the System Environment Variables interface AND a system restart fixed the problem.
Silver lining: I now know C++ and designing GUIs w/ QT and PyQt5
Thanks #albertmand and #jwernerny

Error deploying QT project with Qwt

I'm deploying my QT project to a windows machine and everything worked fine.
Yesterday I add Qwt library to my project and when I deploy it the executable won't start giving this error (On QtCreator everything works fine)
The procedure entry point ?staticMetaObject#QGraphicsEffect##2UQMetaObject##B could not be located in the dynamic link library Qt5Widgets.dll
I think I included all the needed library.
I've tried to use windeployqt,
I've included
DEFINES += QWT_DLL
on the top of my .pro file as read here
but it still give me that error.
Maybe I miss some dependent dll.
Do you have any idea on how to resolve this?
I had the same issue.
I couldn't understand it with dependency walker, as even working apps showed missing dlls.
I used qwt in my program and compiled it in Qt 5.5 with MSVC2013 32bit on a 64bit Windows 10.
After changing 'Qt' folder name to 'QtHidden', as sugested here, I attempted to get the application to run with all the dlls in the same folder and was getting an weird error about qwt like you, althouth I had added qwt.dll.
To get it working I did the following:
Copied all dlls in QtHidden/5.5/mingw492_32/bin to my deploying folder
I copied all folders in QtHidden/5.5/mingw492_32/plugins
Copied all folders in QtHidden/5.5/mingw492_32/qml
// Pretty standard untill now
added qwt.dll
// Now for the trick
Performed the steps 1,2,3 but for the folder QtHidden/5.5/msvc2013, overwriting all dlls and folders previously added from /mingw492_32.
So, what I believe is happening is that some dlls from mingw are needed, like libgcc_s_dw2-1.dll and libstdc++-6.dll, but all other dlls need to come from the MSVC2013 folder for qwt to work, wich was the compiler used.
I managed to run it in Windows Xp 32bit after adding MSVCP120.dll and MSVCR120.dll. Still needed this extra ones because MSVC2013 wasn't installed in the Windows Xp computer.
Compiled in Windows 10 with all resources and ran on Windows Xp. I'd call it a success.
Hope it helps someone else.

Qt5 Application Does Not Run

I created an application using Qt 5 (compiled with Visual Studio '12). It works on my machine.
However, it doesn't work when I attempt to run it on another machine. The output I collected through cmd yielded an empty file.
The directory structure is as follows:
myapp.exe
icudt52.dll
icuin52.dll
icuuc52.dll
libEGL.dll
libGLESv2.dll
msvcp120.dll
msvcr120.dll
Qt5Core.dll
Qt5Gui.dll
platforms/qminimal.dll
platforms/qwindows.dll
The most relevant post I found was Application deployed with QT5 libraries does not start on Windows 7 - yet the solution (including qwindows.dll & qminimal.dll) didn't work.
Any ideas?
Windows will report a number of launch errors just when you double click on your exe outside Qt Creator. It looks like you have included most or all of these already.
Your development machine typically will not have problems launching and running its qt plugins because of the LibraryPaths that are searched by your exe. http://qt-project.org/doc/qt-5/qcoreapplication.html#libraryPaths
Dependency Walker will do the job and show you what you need to know, but the output is pretty complex and can be hard to decipher.
The easiest way I have found to figure out what Qt plugin dlls I am using at runtime on Windows is to do the following:
Exit Qt Creator.
Open the install folder for the compiler you are using with Qt in Explorer. For example:
C:/Qt/5.3/msvc2010_opengl/
Create a copy of the plugins folder in place (Copy of plugins folder in the same path as plugins, so its parent is msvc2010_opengl in this case).
In another explorer window, open your exe (Qt program) on your development machine. Run a minimal test of your program to make sure the major features are working. (Many runtime plugins don't get loaded until QObjects that use them are instantiated).
Delete the plugins folder in the Qt path.
Windows will lock up all the dlls that are in use by your exe and prevent you from deleting a number of dlls. Click skip for all the un-deletable folders and files.
Now go into each of the folders that you couldn't delete before and try to delete all the individual dll's in each folder. Click skip for all the un-deletable dlls.
Now when you are all done, you are left with a skeleton of a plugins folder, only showing dlls that your application is using.
It will probably include the folders: accessibility, platforms and imageformats and more depending on what you included in your .pro file.
Close your exe.
Copy the contents of your stripped down plugins folder to sit right next to your exe.
Restore your backup of the plugins folder (delete the stripped down plugins folder from your Qt path and restore the Copy of plugins).
Now you should be good to go. Test on a non-development machine.
A Note on VS C++ Runtimes
Also on some machines when deploying Qt with MSVC, the msvcrXXX.dll doesn't match what the rest of the system is using. Instead of deploying msvcrXXX.dll, instead in our installers at our office, we include the Microsoft C++ Redistributable Installer and run it in the install script. And on a few machines they had corrupted Redistributables, and we had to do a force install of redistributables to fix the `Referral from server' error we would sometimes get.
You can find the latest installer for MSVC Redistributables here Latest Supported Visual C++ Downloads.
Hope that helps.
You have to deploy your application before copying dll files manually.
To deploy your Qt application on Windows you can use windeployqt which can be found in:
< QTDIR >/bin/windeployqt
Example batch script may work on deploying your Qt Application (run with PowerShell or cmd):
C:\Qt\Qt5.x.x\5.x.x\MSVCx_x\bin\windeployqt <APP_PATH>/myapp.exe
After deploying your app, try to run your myapp.exe and note which dll files are missing.
Copy / paste required dll files from QTDIR/bin to your < APP_PATH >
for more information about deploying:
Windows Deploying Tool - windeployqt
Deploying on Windows

Error while trying to run a release build of a Qt application on Windows

I'm trying to build the Windows version of my app. The program compiles and runs fine on Qt Creator but when I try to run it standalone it throws the following error:
The procedure entry point _Z17qt_message_output9QtMsgTypePKc could not be located in the dynamic link library QtCore4.dll
I have all the necessary dlls in my application folder and they are the same ones that came with the binaries I've downloaded from the Qt's website. This error is driving me crazy for I can't seem to find any reason for it. The application runs fine on Linux and MAC OS X.
Ok I found the problem. I was copying the wrosng dll (not sure why Qt ships with 2 different versions).
The right ones are in:C:\Qt\2010.05\qt\bin and NOT in C:\Qt\2010.05\bin
I hope this helps anyone who might stumble upon this issue.

wxWidgets running on other machine

I created application which uses wxWidgets library using visual studio 2008. Now I would like to create version which may be run on other machine.
Because right now when I want to run It on another machine there is an error:
the application failed to start because its side-by-side configuration is incorrect.
What can I do to make It work ?
The Event Viewer should have a record showing what DLL was being searched for, what version of that DLL if found in the SxS cache, and what version it was looking for but couldn't find. You'll then want to (for example) include the correct version of that DLL to be installed with your program. Alternatively, just link to virtually everything statically -- it'll make your executable a lot bigger, but eliminate a lot of problems like this relatively painlessly.