QT missing dll after deploy - c++

I've copied all of the dlls from QT that were required, and my application works fine on my Windows server machine.
However when trying to run it on a Windows 7 box i get the following message:
This application failed to start because it could not find or load he
Qt platform plugin "windows".
Reinstallning the application may fix this problem.
Any ideas what I'm missing here?

I'd scratched my head over this some time ago. It turned out that this was caused not by missing qwindows.dll, but rather one of libEGL.dll or libGLESv2.dll. This was tricky, because dependency walker does not show those libs as direct dependencies.
If you want to test on your dev machine, whether your app has all required libs, fire up console issue SET PATH=, cd to your app directory and run it.
This is complete list of dlls that my app is using (Qt 5.2 / QtQuick app only, rest is C++). QtQuick is nice but the size of Qt dependencies is a bit scary:
icu*.dll - depending on whether you've compiled with ICU
libEGL.dll
libGLESv2.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Network.dll
Qt5Qml.dll
Qt5Quick.dll
Qt5Widgets.dll

Widely used solution is put all necessary libraris in the folder of application.
What are libraries application need?
Run application and see error message:
The program can't start because <Library name> is missing from your computer.
Try reinstalling the program to fix this problem
Library set is depended from Qt version. Run several times application and each time copy required lib you found what is neeeded for application.
In my case (Qt 5.2.1) there are
icudt51.dll,
icuin51.dll,
icuuc51.dll,
libgcc_s_dw2-1.dll,
libstdc++-6.dll,
libwinpthread-1.dll,
Qt5Core.dll,
Qt5Gui.dll,
Qt5Widgets.dll.
All libs you can found in your Qt install folder. But don't use libraries from Tools\QtCreator folder, because QtCreator has another version of these libraries!
In case of error:
This application failed to start because it could not find or load he Qt platform plugin windows. Reinstallning the application may fix this problem.
You should create folder platforms and copy qwindows.dll into it.
If you still got error you should create qt.conf file in application's folder with content:
[Paths]
Plugins=plugins
This solution is described in https://qt-project.org/forums/viewthread/37265
More information about qt.conf you can find at http://qt-project.org/doc/qt-5/qt-conf.html
In latest versions of Qt you can find deploy tool (since 5.2). This tool find necessary libraries for application and copy into application folder. You can run it something like this:
call c:\Qt\QtX.Y.Z\X.Y.Z\mingw48_32\bin\qtenv2.bat
cd /d "c:\path\to\your\application\folder"
windeployqt.exe your_application.exe
Generally it works well. But I notice that some libraries are not copied, but you can found by method is descibed at beggining of post. More useful information you can find at
http://qt-project.org/doc/qt-5/windows-deployment.html
In rare cases yo can got this error if some library is missing but not appear in error message above. Example: Qt 5.1.1: Application failed to start because platform plugin "windows" is missing
I wasn't in this situation, so I can't tell more.

Related

What leads to "Could not find QtWebEngineProcess" error?

I am triyng to port WebKit (Qt5.5.1) plugin to WebEngine (Qt5.11.3) one as described here: https://doc.qt.io/qt-5/qtwebenginewidgets-qtwebkitportingguide.html
Building and running in Ubuntu 18.04 I get following errors:
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
and then
Could not find QtWebEngineProcess
I am not sure if first one is related to second but second one leads to crash.
EDIT:
I put QtWebEngineProcess from Qt/libexec dir to dir with binary and now second error changed to:
WebEngineContext used before initialize() or OpenGL context creation failed.
still crashes.
Problem was in missed dependency files.
Our cmake build copied only auto-determined dependencies (libs) from the Qt folder to the app folder. But for a full deploy a QtWebEngine app needs few non-libs dependencies such as QtWebEngineProcess executable xcbglintegrations plugins (first error) and WebEngine resources. This instruction https://doc.qt.io/qt-5/qtwebengine-deploying.html have most of details.
It worked for me with Qt5.12.9. With Qt5.11.3 I still had some problem.

How to deploy QWindowsIntegrationPlugin with CMake

I'm using CMake to build a Qt application. My project compiles, and thanks to 'fixup_bundle()', make install copies the required libraries next to my executable. Great!
Only problem is, when I execute it, I get the dreaded 'This application failed to start because it could not find or load the Qt platform plugin "windows".' error.
Indeed, manually copying qwindows.dll into a 'platforms' directory next to the executable fixes the issue. Now, how can I tell CMake to do that automatically?
Not much info from Qt :
Plugins are also available as IMPORTED targets in CMake. The Qt Network, Qt SQL, Qt GUI, and Qt Widgets modules have plugins associated. They provide a list of plugins in the Qt5_PLUGINS variable.
All right, I guess I have to play with Qt5::QWindowsIntegrationPlugin, which should be an imported target. That's where I'm lost.
I know (well, I think I know at least) that fixup_bundle() looks into the executable to find its dependencies. But despite the fact that I link my executable against QWindowsIntegrationPlugin, there is no trace of it. Therefore, no qwindows.dll copied into my output path by fixup_bundle().
Except the manual copy of the file, I couldn't find a nice CMake-friendly answer to this issue.
Thanks for your help.
Just ran into the same issue. Here is how I resolved it in my CMake install script:
# QWindowsIntegrationPlugin is part of the Gui component
find_package(Qt5 COMPONENTS Gui REQUIRED)
install(
FILES "$<TARGET_FILE:Qt5::QWindowsIntegrationPlugin>"
DESTINATION bin/platforms
)

Qt application deployment

What are the necessary dll files to deploy an application using Qt? By necessary I mean those who are common to all applications, not the entire dll folder. Are msvr120.dll and msvc120.dll necessary too? Thanks to further answers.
Dependency Walker is your best friend in this case.
In short, it depends on how many Qt modules you used in your project.
Check your project file, for example:
QT += core gui script
Then you will need
QtCore4.dll / Qt5Core.dll (QtCored4.dll / Qt5Cored.dll for debug)
QtGui4.dll / Qt5Gui.dll
QtScript4.dll / Qt5Script.dll
which can be found in bin folder under Qt directory.
As for msvr120.dll and msvc120.dll. You may distribute them as well, in case your user's Windows system doesn't have them (e.g. older version like Windows XP, but I am not sure whether those dlls work in older version of Windows)
Windows Qt installations include windeployqt.exe deployment helper which will copy Qt(and MinGW if you use it) library .dlls. Check your Qt installation directory, it's in same as qmake.exe
Basic usage from cmd: (Replace --debug with --release for release builds)
mkdir Deploy
copy /y /path/to/exe Deploy
cd Deploy
windeployqt.exe --debug Prog.exe
Aside from required .dll files it will also put optional plugins, translation files and configuration files for everything. You can later remove non needed files and upx the rest.
Additional info here: Qt for Windows - Deployment (thanks peppe for link). windeployqt.exe is mentioned at the bottom of the page.
Note: It can't deploy MSVC runtime libraries. You need a redistrubutable for them, so you can silently install them with your installer.

How to run a Qt Program without Qt itself being installed?

I have written a program with Qt5.3.1 and run it on my development machine where it works fine. I copied all necessary .dll files into the folder where my .exe is. These are:
Qt5Widgets.dll
Qt5Network.dll
Qt5Gui.dll
Qt5Core.dll
icudt51.dll
icuin51.dll
icuuc51.dll
libgcc_s_dw2-1.dll
libwinpthread-1.dll
libstdc++-6.dll
Now I want to run that program on a machine that has no Qt installed. How do I do that? It shouldn't be necessary for users to install an IDE just to use a program, right?
Details of the development machine where it works:
Windows 8
Qt 5.3.1
The deploying platform is:
Windows Vista
No Qt installed but all necessary .dlls are in place
Errors I get are first:
This application failed to start because it could not find or load the Qt platform plugin "windows".
Reinstalling the application may fix this problem.
Next error message is:
This application requested the Runtime to terminate in an unusual way. Please contact support.
Then the program crashes. But if I install Qt5.3.1 it works. So it has something to do with files in the c:/Qt directory
This application failed to start because it could not find or load the Qt platform plugin "windows".
For this problem, you should copy the plugin {QTSDK}/plugins/platforms/qwindows.dll to {YOUR_EXE_DIR}/platforms/qwindows.dll.
The short answer is you either need to do a static build, or you need to redistribute the Qt shared library DLLs. If you're looking for a smaller file size static builds are often better, but there may be legal implications with this approach if you're using Qt5 under a LGPL license. I'm not a lawyer, but you can read about LGPL linking rules in LGPL section 4.1.
The long answer is you should read the general Qt5 deployment guide and the Qt5 for Windows deployment guide. These go into quite a bit of detail.
A better solution is to use the Qt SDK application "windeployqt". It is used to copy all the required dlls and plugins to your application folder based on target platform. You can then run that on another computer. Here is the documentation: https://doc.qt.io/Qt-5/windows-deployment.html.
For example, if your executable was built using mingw53_32 and your executable is in "C:\example_qtapp":
QT_INSTALL_DIR\minqw53_32\bin\windeployqt.exe c:\example_qtapp
I have encountered this problem as well,
In your Qt Directory, with the proper Qt version
C:\Qt\Qt5.2.1\5.2.1\mingw48_32\plugins\platforms\
copy qwindows.dll into a new folder that lives next to your executable, such that your list would be
Qt5Widgets.dll
Qt5Network.dll
Qt5Gui.dll
Qt5Core.dll
icudt51.dll
icuin51.dll
icuuc51.dll
libgcc_s_dw2-1.dll
libwinpthread-1.dll
libstdc++-6.dll
platforms/qwindows.dll
You should place Qt DLLs along the release version of your executable. These are Qt5Core.dll, Qt5Gui.dll and possibly the ones for other modules that you have used. These dll files are in your installed Qt Directory in bin folder. You should also place LIBGCC_S_DW2-1.DLL, MINGWM10.DLL and LIBSTDC++-6.dll in case you are using MinGW.
If you are using plugins you should place their dll in a folder named plugins beside your exe. In case of using icons and images you should ship their dlls like qico.dll and qsvg.dll in a folder named imageformats.
if Qt dlls are there, they it should work. My guess is that you are missing the run time libraries/dlls of your IDE. For example, if you are using Visual Studio 2010 as your IDE, then you need to install VS2010 Redistributable x86/x64 link depends on your architecture.
You should also copy {QTSDK}/plugins to directory where you executable located. Then create qt.conf in the same place (with executable) with the following content:
[Paths]
Plugins=plugins
Thеn, run your program. I did the same on linux.
In your application folder hold down SHIFT key and right click from mouse.
You will see - Open command window here
Click Open command window here
TYPE windeployqt.exe app_name.exe --parameters and HIT ENTER
Example:
windeployqt.exe APP_NAME.EXE --release --no-translations --no-system-d3d-compiler --no-compiler-runtime --no-angle --no-opengl-sw

What dlls do i need to distribute my Qt application?

I built a Qt app that I'd like to distribute to a few people.
On a computer with QtCreator installed, I can get it to run by placing a bunch of Qt dlls (I inserted the ones it complained about) inside the same folder as the executable. But if I uninstall Qt or try it on a computer without Qt, the executable does nothing. No error, just no window or process when I run it.
Here's what I've tried:
-put every dll from the qt folder with the executable. No effect.
-run it with dependency walker. I'm not entirely sure I'm using it right but, with Qt uninstalled and the necessary dlls with the executable, it doesn't give me any missing or invalid modules. Just a couple of red lines in the logger after profiling like:
GetProcAddress(0x75AC0000 [KERNEL32.DLL], "SetDefaultDllDirectories") called from "MSVCR110.DLL" at address 0x6AC0FD4F and returned NULL. Error: The specified procedure could not be found (127).
and
GetProcAddress(0x75AC0000 [KERNEL32.DLL], "GetCurrentPackageId") called from "MSVCR110.DLL" at address 0x6AC0FDFA and returned NULL. Error: The specified procedure could not be found (127).
Nothing related to qt that I can tell.
I'm testing on a virtual machine (trying to simulate a non-dev machine) with 32bit windows 7. MSVC redist 2010 and 2012 are installed.
It's Qt 5.1.0 MSCV2012-32bit. And I have the same problems with the 64bit version (I haven't used dependency walker with the 64 bit version though).
Is there some step I'm missing?
I have found you need to add a sub directory with some of the plug in dlls found in the plugin subdirectory of the install folder (where you find the include and bin folder)
in particular the platforms subdirectory and the qminimale.dll and windows.dll in it are needed for a gui
edit: to be clear add a subdirectory platforms to the directory with the exe and add the qminimale.dll and windows.dll to it