Combining Dependent DLL Files with Executable using windeployqt

69 Views Asked by At

Using the windeployqt tool, all dependent files necessary for running the program are placed alongside the executable file. I want to merge these dependent files, which have the .dll extension, with the executable file having the .exe extension. This means that for distributing and running the program, I only want to have one executable file (.exe).

I would appreciate it if you could guide me through this process.

1

There are 1 best solutions below

4
Parisa.H.R On

To achieve a single executable file without external DLL dependencies in Qt, you can use static linking instead of dynamic linking. Static linking includes all necessary libraries directly into the executable, so you won't need separate DLL files.

you need to add

CONFIG += static

in your .pro file and also you need to change your qmake configuration. This means you must build Qt statically by configuring Qt with -static.

If you've installed Qt online using the pre-built binaries provided by the Qt Company, you won't be able to configure Qt for static building from the installed files directly. The pre-built binaries are configured by the Qt Company to support dynamic linking by default, and they are not designed to be reconfigured after installation.

To build Qt statically, you must download the Qt source code and compile it yourself with the desired configuration options.

./configure -release -static -opensource -confirm-license -prefix /PATH/BUILD-STATIC

Please watch this YouTube video :

https://www.youtube.com/watch?v=chMNUzpN4pw

Also, you can read more from This Qt Documentation :

https://doc.qt.io/qt-6/windows-deployment.html