I've build qt for static linking to make just one exe without any dll's, configured creator. On my computer everything works. But when i run a program on other computers nothing happens. Process starts, but nothing is shown. And it's only with qml, it works with c++ projects.
I tried to make a simple exe and add all needed libraries by windeployqt, but it doesn't change anything.
Maybe someone can tell me, what am i doing wrong?
I have found that with QML applications you might need directories from the following directory:
..\Qt5.3.2\5.3\msvc2013_opengl\qml\
The directories needed depends on what you have included.
For my application I had the following structure:
my.exe
QtGraphicalEffects
QtQuick
QtQuick.2
First run the mingw on cmd terminal of windows (on my case it is on C:\Qt\6.1.1\mingw81_64\bin).
After this go to your project output (where is your .exe file that you want to run on another windows machine).
Run the windeployqt command:
windeployqt.exe --qmldir C:\Qt\6.1.1\mingw81_64\qml .
I run the example project "Qt Quick Application - Scroll".
The blank screen only happens on PCs that do not have a video card with OpenGL 2.0 support.
Try this:
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
Try copying every DLLs in below folder to the folder where your exe is.
C:\Qt\x.x.x\msvc20xx_xx\bin\
If the exe runs normally, try deleting the DLLs some by some to find out what dll is needed and what is not needed.
Related
I have built a very simple calculator in Qt. When I run it in release mode from qt creator, everything works fine. However when I go to the release folder and run it, it gives QT5Core.dll, QT5Widgets.dll and QT5Gui.dll not found. After running windeployqt there by:
windeployqt .
All the dll get added. However, it then gives error VCRUNTIME140_APP.dll and MSVCP140_APP.dll not found. After copying them to the folder. The exe doesn't give any error on double clicking but just does not start. What should I do?
I found this solution here, however I cannot find any qml file in the application directory.
I created it as a QT widget application. I am using Windows 10 with Visual Studio 2017 and MSVC2017 64bit desktop kit. The application is in C++.
Update:
Running the command
windeployqt Calculator.exe
after adding qt to the path seems to do the trick. Application working even after removing qt from the path. Will try running the app inside vm just to be extra sure.
When running from the command line, add your Qt Bin directory to the PATH. For example:
C:\> PATH=C:\Qt\Qt5.11.0\5.11.0\msvc2017_64\bin;%PATH%
You can solve the problem as selbie described it. An another way is to copy the missing .dll-Files to the folder where the.exe is placed.
See here https://doc.qt.io/Qt-5/windows-deployment.html#creating-the-application-package :
To deploy the application, we must make sure that we copy the relevant Qt DLLs (corresponding to the Qt modules used in the application) and the Windows platform plugin, qwindows.dll, as well as the executable to the same directory tree in the release subdirectory.
set variable VCINSTALLDIR, example:
set VCINSTALLDIR=p:\Programs\Microsoft Visual Studio\2017\Community\VC\
and next run
windeployqt.exe app.exe
Or copy vc_redist.x64.exe from Redist subfolder into folder with your application.
As #mosa mentioned, To deploy the application, we must make sure that we copy the relevant Qt DLLs (corresponding to the Qt modules used in the application) and the Windows platform plugin, qwindows.dll, as well as the executable to the same directory tree in the release subdirectory.
To add missing .dll files first open QT MSVC Console and type windeployqt.exe command,
Then you have to go to the directory which .exe file contains. Let's assume my .exe is in the desktop,
C:/
cd user/indrajith/desktop
Then you can add missing .dll files using following command,
windeployqt.exe --quick.
Finally, just double click your .exe file to run the program.
Simple Solution:
Copy "bin" and "plugins" folders from the qt setup directory(C:\Qt\6.2.4\mingw_64) to your release folder.
Put your .exe file inside that "bin" folder and done.
Now, your .exe application should run.The bin and plugin folders contain required .dll files and unnecessary files can be removed manually.
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?
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.
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:
copy built exe binary to a new folder
open cmd console in that folder
call windeployqt 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.
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
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
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:
I install Qt to c:\Qt\...
I develop an app and deploy it correctly somewhere else.
It runs on any computer properly because it includes qwindows.dll in a subdirectory.
I upgrade my local Qt to a new version.
I try to run my app again.
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=.
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.
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]
Close Qt Creator.
Copy the following into C:\Deployment\ The release version of MyApp.exe All the .dll files from
C:\Qt\5.2.1\mingw48_32\bin\ All the folders from
C:\Qt\5.2.1\mingw48_32\plugins\
(If you used QML) All the folders from C:\Qt\5.2.1\mingw48_32\qml\ Rename C:\Qt\ to C:\QtHidden\ (This turns your PC into a clean environment, just like one that doesn't have Qt installed).
Launch C:\Deployment\MyApp.exe.
Now for the hack -
Duplicate your folder for safety
If your file was in /cat/Deployment, go to /cat
Now, delete the Deployment folder while the .exe is still running.
It will tell you that it cannot delete certain files, so say Skip(or skip all)
What you're left with is the list of all the .dll files that your .exe was actually using and could not delete: the list of all the files and only the files that you need to keep.
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.
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.
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
...
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()
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 fixed this by placing qt.conf in my application's exe folder:
[Paths]
Prefix=C:/Qt/Qt5.11.2/5.11.2/msvc2017
Where:
I have installed a custom Qt kit in 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 (!)
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.
Tried all the above - turned out for me it was simply because I didn't have the main Qt dlls in the apps folder
Qt5Core.dll
Qt5Widgets.dll
etc
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.
When I copy project folder - was build and generate to bin folder - from my computer to anothers. It show "The program can't start because QT5core.dll is missing".
Will I install QT to another computer for get all of QT dll - It arround 2gb. I think it's not good solution. Because when I want to transfer it to customer. He will not like to install this software for just seeing program.
I tried to use NSIS but I don't know how to get dll from my machine. And what dll will I need for move to build folder.
Thanks for any solution from you.
May be your required dependencies not installed on target machine, do as following answer, it gets solved:
Qt 5.0 program runs in QtCreator but not outside
You don't need to install anything on the other computer. Just try going to the location where your Qt application is installed and then navigate to "..\Qt\mingw53_32\bin" directory. The search for the missing .dll files, copy them to the location where your .exe file is situated and then re-run the application.
I am developing a Qt 5.0 dekstop application using mingw47. I use QtMultimedia in this application to record and play audio. I have tested it for debug and it works. When I try to build it for release and run the executable file, I can't play the audio file that can normally be played in debug mode. I've added the following dlls before running the executable file:
D3D_Compiler_43.dll,
icudt49.dll,
icuin49.dll,
icuuc49.dll,
libEGL.dll,
libgcc_s_sjlj-1.dll,
libGLESv2.dll,
liblibmpeg2_plugin.dll,
libstdc++-6.dll,
libwinpthread-1.dll,
Qt5Core.dll,
Qt5Gui.dll,
Qt5Multimedia.dll,
Qt5Network.dll,
Qt5Widgets.dll,
Qt5Xml.dll,
plugins/platforms/(all dlls),
plugins/mediaservice/(all dlls),
plugins/playlistformats(all dlls)
What is probably wrong? Or what other dlls am I missing?
UPDATE: Use windeployqt.exe! It works really well.
http://doc.qt.io/qt-5/windows-deployment.html#the-windows-deployment-tool
The simplest way to use windeployqt is to add the bin directory of
your Qt installation (e.g. ) to the PATH variable and then
run:
windeployqt <path-to-app-binary>
While you are running your application in release mode (when it is working, ran from inside Qt Creator), execute depends.exe and point it at the application.
Make note of all the dlls that are referenced from your Qt folder.
Alternate way if you want to take more time with it:
You can figure it out by hand by trying to delete files because Windows won't let you delete a folder or a dll while it is in use. So you could go and make a back up of your Qt installation, and then run you application, make sure it has connected to all the dll's it is going to use, and then try to delete folders and files in your Qt installation. Windows won't let you delete files that are in use by your release.
Also here is how Windows resolves dll's if you wanted to know:
http://msdn.microsoft.com/en-us/library/7d83bc18(v=vs.80).aspx
EDIT: Also, you don't need to make the folder called plugins in your exe directory. It should be something like this:
Qt 4.x:
./myexe.exe
./QtCore.dll
./imageformats/qjpegd4.dll // Note: there isn't a "plugins" folder here
Qt 5.x: (take from here)
The executable ./plugandpaint.exe
The Basic Tools plugin ./plugins/pnp_basictools.dll
The ExtraFilters plugin ./plugins/pnp_extrafilters.dll
The Qt Windows platform plugin ./platforms/qwindows.dll
The Qt Core module ./Qt5Core.dll
The Qt GUI module ./Qt5Gui.dll
The Qt Widgets module ./Qt5Widgets.dll
Also run qDebug() << QApplication::libraryPaths(), and make note of paths that are searched for dlls on your computer.
Hope that helps.
All of the DLL's in your list that have their import libraries linked to the application will be automatically loaded by the OS. If any of them are missing you will get a dialog telling you which DLL it failed to load. The only ones that look like they might be loaded manually by the application are the plugins. Make sure you are telling the QT multimedia system to load the them. Also make sure you check the error codes returned by the multiamedia manager.
Given your recent comment that the audio plays in debug mode but not in release mode is a good indication you have put the plugin DLL's in the wrong place. When you launch your application from Explorer or the command line the plugins directory needs to be in the same directory as the application. Your directory structure should look something like below
c:\stackoverflow\myprogram.exe
c:\stackoverflow\plugins\platforms\(all dlls)
c:\stackoverflow\plugins\mediaservice\(all dlls)
c:\stackoverflow\plugins\playlistformats\(all dlls)
c:\stackoverflow\D3D_Compiler_43.dll
c:\stackoverflow\icudt49.dll
... other dll's here...
c:\stackoverflow\Qt5Network.dll
c:\stackoverflow\Qt5Widgets.dll
c:\stackoverflow\Qt5Xml.dll
I've found the answer. Now my application works. It can play audio file while running the executable file.
Although not listed in depends.exe, we should add the following dlls when using QMediaPlayer:
Qt5MultimediaWidgets
Qt5OpenGL
Here is the reference: https://bugreports.qt-project.org/browse/QTBUG-30172
Hi Im trying to execute my .exe file from the debug folder.
Now before you go telling me about all the other related articles Ive looked at them all and their solutions are not helping with my problem.
Ok first off Im using Qwt library and trying to create a set of gauges. I got a gauge working now I need to get it to execute from the .exe.
Ive tried adding the platforms folder in with my directory and adding the windowsd.dll and minimald.dll but still does not work.
Please advise on any course of action this had got me stumped.
Also one post says to create a qt.conf file and place it in the directory but I cant find out how to make a .conf file.
UPDATE
the error reads
debug error!
Program:
...build-Desktop_Qt_5_0_1_MSVC2010_32bit-Debug\debug\gauge.exe
Module:5.0.1
File: kernel\qguiapplication.cpp
Line:781
Failed to load platform plugin "windows". Available platforms are:
minimal
Windows
When deploying Qt on Windows, you have to copy over a number of the dlls from the bin folder of the Qt directory.
On my system it is:
C:\Qt\4.8.4\bin
After you copy over all the required dll's from there, like QtCore4.dll and QtGui4.dll, if you are using any additional plugins like phonon or jpeg support, you need to copy those dll's over from the plugins folder:
C:\Qt\4.8.4\plugins
For example I make a folder in the folder with my exe called imageformats and I put qjpeg4.dll in that folder.
As far as Qwt works, you probably need to do a similar process to expose those dll's to your exe, and put them in the same folder as your exe.
The dll's listed above are for the "release" build of your exe. If you are running the "debug" version, it will look for <dll_name>d.dll.
The reasoning for putting in those paths has to do with the library search order that windows uses.
Qt, Phonon and multimedia codecs: how to bundle them?
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx
http://qt-project.org/doc/qt-4.8/deployment-windows.html#creating-the-application-package
Hope that helps.
If you have several executable and\or you don't want to copy plugins by hand, you can create a qt.conf file with the path to the plugin directory
[Paths]
Plugins = PATH_TO_QT_DIR/plugins
You need to place the qt.conf file where the executable is.
More information at http://doc.qt.io/qt-5/qt-conf.html