windeployqt copies a lot of unneeded files - qt

I am using windeployqt to create an executable with the correct dependencies for a very simple Hello World type QML application. When using this, with the command
windeployqt . --release --qmldir D:\Documents\QT-Projects\HelloQML
in a folder with the executable in. This works fine, and I can run the executable with no problem. However, I have found that I can delete many of the files and folders in the directory with no consequence on running the program. For comparison, here is the original folder contents.
And here is the folder after I have deleted all of the things I could, while still allowing the program to run (I did not try deleting anything in any of the subfolders).
Is there a way for windeployqt to not copy so many unnecessary items?

If you use one of the latest Qt versions you can select which files not to copy.
A binary which doesn't use translations and OpenGL, can for example use:
windeployqt.exe C:\sample\sample.exe --no-translations --no-opengl-sw
For more information you can run:
windeploy --help
Usage: windeployqt [options] [files]
Qt Deploy Tool 5.12.0
The simplest way to use windeployqt is to add the bin directory of your Qt
installation (e.g. <QT_DIR\bin>) to the PATH variable and then run:
windeployqt <path-to-app-binary>
If ICU, ANGLE, etc. are not in the bin directory, they need to be in the PATH
variable. If your application uses Qt Quick, run:
windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>
Options:
-?, -h, --help Displays this help.
-v, --version Displays version information.
--dir <directory> Use directory instead of binary directory.
--libdir <path> Copy libraries to path.
--plugindir <path> Copy plugins to path.
--debug Assume debug binaries.
--release Assume release binaries.
--pdb Deploy .pdb files (MSVC).
--force Force updating files.
--dry-run Simulation mode. Behave normally, but do not
copy/update any files.
--no-patchqt Do not patch the Qt5Core library.
--no-plugins Skip plugin deployment.
--no-libraries Skip library deployment.
--qmldir <directory> Scan for QML-imports starting from directory.
--no-quick-import Skip deployment of Qt Quick imports.
--no-translations Skip deployment of translations.
--no-system-d3d-compiler Skip deployment of the system D3D compiler.
--compiler-runtime Deploy compiler runtime (Desktop only).
--no-compiler-runtime Do not deploy compiler runtime (Desktop only).
--webkit2 Deployment of WebKit2 (web process).
--no-webkit2 Skip deployment of WebKit2.
--json Print to stdout in JSON format.
--angle Force deployment of ANGLE.
--no-angle Disable deployment of ANGLE.
--no-opengl-sw Do not deploy the software rasterizer library.
--list <option> Print only the names of the files copied.
Available options:
source: absolute path of the source files
target: absolute path of the target files
relative: paths of the target files, relative
to the target directory
mapping: outputs the source and the relative
target, suitable for use within an
Appx mapping file
--verbose <level> Verbose level (0-2).
Qt libraries can be added by passing their name (-xml) or removed by passing
the name prepended by --no- (--no-xml). Available libraries:
bluetooth concurrent core declarative designer designercomponents enginio
gamepad gui qthelp multimedia multimediawidgets multimediaquick network nfc
opengl positioning printsupport qml qmltooling quick quickparticles quickwidgets
script scripttools sensors serialport sql svg test webkit webkitwidgets
websockets widgets winextras xml xmlpatterns webenginecore webengine
webenginewidgets 3dcore 3drenderer 3dquick 3dquickrenderer 3dinput 3danimation
3dextras geoservices webchannel texttospeech serialbus webview
Arguments:
[files] Binaries or directory containing the binary.

Some of these files may be needed when deploying your Application to another PC.
For Example you deleted the opengl32sw.dll.
I found that this dll is not present on all PCs and needs to be part of the installation.

Related

Can not load library Qt5Widgets.dll

Error when run FBLTool_0224.exe
I guess you double-clicked in exe file that provides after building in release mode :
For Deploy and create Exe output with QT in windows you should follow this way:
put your compiler path in your system path. now you use mingw81_64 you should set it. something like Qt/tools/mingw81_64/bin
copy exe file that provides after building in release mode in one folder and run mingw81_64 cmd (it has separate cmd)
and cd to that folder path
windeployqt app.exe
This command will get all dll needs for your app and your exe will work .
if you use qml
windeployqt --qmldir (the path of its directory ) app.exe
and also see these youtube videos for more info:
https://www.youtube.com/watch?v=LdSTgR0xJco
https://www.youtube.com/watch?v=hCXAgB6y8eA
installing visual C++ 2010 runtime x86 solved problem

Qt deployment for windows copies incorrect dll for mingw

I set this build step to add deployment DLLs to my release folder:
Command: %{Qt:QT_INSTALL_BINS}/windeployqt.exe
Arguments: "%{CurrentProject:NativePath}\bin\server.exe" --no-translations
The correct QtXXXX.dll files are copied, but incorrect libstdc++-6.dll is added. The correct one is located at QTDIR/bin/libstdc++-6.dll, but instead, windeployqt.exe copies this DLL file from C:\MinGW\bin. If I try to run the application, I get this error:
How can I tell windeployqt.exe to copy mingw files from %{Qt:QT_INSTALL_BINS} instead of my MinGW installation folder?
The version of Qt I am using is Qt5.6.0-MinGW with mingw49_32.
If you don't use the batch file that sets up the environment and comes with Qt then just make sure that the first compiler g++.exe found be windeployqt.exe is the one coming with Qt and not the one that got installed with MinGW. This way the correct library will get copied.
As an example from my own current installation:
Qt is installed to C:\Qt\Qt5.8.0 and MinGW to C:\MinGW. Hence I add C:\Qt\Qt5.8.0\Tools\mingw530_32\bin before C:\MinGW\bin to my PATH. These two paths each contain a compiler g++.exe.

mingwm10.dll missing in the bin folder

I was trying to create a exe file of my Qt project.
I found this post: How to create executable file for a Qt Application?
and realised that i dont have a mingwm10.dll file in that directory.
Are there any other ways of creating a exe file or any other location where mingwm10.dll might be located?
I am using qt 5.6.
mingwm10.dll is a runtime file for the MinGW.org toolchain. Qt moved towards a MinGW-w64-based toolchain (which is essentially an expanded and newer implementation of the Win32 headers and import libraries), which doesn't have this runtime dependency. Ignore it, you don't need it. You might need the libgcc and libstdc++ DLLs though, but that's the same with any (non-statically built) toolchain.
Note you can use the windeployqt utility to automatically copy over all runtime depencies of an executable. You can enable it by adding windeployqt to CONFIG if you're using qmake, or you could just run it yourself:
windeployqt my_app.exe
This command will copy all DLLs (including the Qt platform plugins etc.) so that the application can be run by e.g. double-clicking, instead of only in the specific environment of an IDE.

Qt program deployment

In one of my programs I use QWebView to load and print reports made from HTML documents. So while deployment I copy these libraries, in additional to all other relevant Qt libraries:
Qt5WebKit.dll
Qt5WebKitWidgets.dll
Qt5PrintSupport.dll
plugins/printsupport/windowsprintersupport.dll
After testing on destination machine I've found that printing doesn't work. Thanks for Dependency Walker I've get all the missed libraries. Here is the list:
Qt5Multimedia.dll
Qt5Positioning.dll
Qt5MultimediaWidgets.dll
Qt5Qml.dll
Qt5Quick.dll
Qt5Sensors.dll
Qt5OpenGL.dll
Ok, I can understand why it wants Qt5Multimedia.dll. Browser can play sound etc. But QML! Why I need all these libraries related to QML?? I don't use neither OpenGL nor sensors or positioning. So it's just unnecessary in my case.
And so my question - is there way to deploy only libraries I need in actual fact? And get the program work of course.
I would suggest you to use windeployqt.exe.
From the docs:
The Windows deployment tool can be found in QTDIR/bin/windeployqt. It
is designed to automate the process of creating a deployable folder
that contains all libraries, QML imports, plugins, translations that
are required to run the application from that folder. This is used to
create the sandbox for Windows Runtime or an installation tree for
Windows desktop applications that can be easily bundled by an
installer.
This is how I do:
cd [my program dir]
mkdir RELEASE
cd RELEASE
copy ..\"progname.exe" .
set QTDIR=C:\Qt\Qt5.4.1\5.4\mingw491_32\bin
call %QTDIR%\qtenv2.bat
windeployqt --force "progname.exe"
You could adapt that for your need by changing [my program dir] to your application's folder (containing the .exe file), QTDIR to your Qt MinGW folder (that's what I use) and progname.exe with the name of your executable file.
It will create a release directory with your executable and the needed Qt libraries (.dll's, etc).

Getting an empty window while Deploying a QML Desktop application on Windows

I just finished writing a QML desktop application(with QtCreator and c++) on Windows.
I've installed QT Quick Desktop Components, according to these instrctions, with MinGw compiler, in C:\QtSDK\Desktop\Qt\4.7.4\mingw\imports\Qt\labs\components folder.
I installed it twice - once for debug - with the command: qmake && jom debug && jom install, and once for release - with the command: qmake && jom release && jom install, so I have now two dll files: 1.styleplugin.dll, 2.styleplugind.dll. and I'm using each of them when I need it. I've imported it to my application with:
import Qt.labs.components 0.1
Now I have to deploy my application, and make it work on all the machines: with Qt installed on it, or with no.I tried to do it with these steps:
coppied these files: application.exe, QtCore4.dll, QtGui4.dll, QtNetwork4.dll, styleplugin.dll and styleplugind.dll.
but when I'm running the .exe file - I'm getting a white, empty screen.
(BTW, when I'm running the .exe file from it's release folder - I can see again only a white window, and when I did the same to a simple Widget GUI application - it runs well from there).
Do you know about any reason to this situation?
Any answer would be appreciated!
May be you forgot deploy QML files to exe? (qrc)
Simple way to test it is copy folde with qml-files to destination near exe file
UPD:
Please read Qt Resource System article
I.e.:
First need add new "Resource File" in project menu,
Then place all of your qml files into this resource file
Change "Source" in your QDeclarativeView like a:
viewer->setSource(QUrl("qrc:/main.qml"));
One possible solution is to enable warnings by running the command
qmlviewer.exe -warnings show qmlfilename.qml
If qmlviewer cannot find any dependent import libraries, it will show up here.
To make sure qmlviewer can access the import libraries either use the -I <directory> on the command line
OR set the QML_IMPORT_PATH environment variable to the folder containing the import libs.
eg:
qmlviewer.exe -warnings show -I <directory> qmlfilename.qml
OR
set QML_IMPORT_PATH=<directory>
where <directory> is the module import search path (without the <>)

Resources