Customizing the ICU
DLLs from the ICU are actually heavy, especially with icudt5*.dll
But there is a way to customize this DLL using the ICU Data Library Customizer , so you can greatly reduce your size, as quoted in the Qt forum
Reduced examples:
Using Dependency Walker
One feature you can use to detect the required DLLs in your project is the Dependency Walker , it will help you to detect only the required dlls, using:
Most important of all is that you should rename the /Qt/QtX.X.X
folder to something like /Qt/QtX.X.X-tmp
, as some DLLs may be "registered"
Initially the folder with its EXE should not have any DLL except the Qt5Core
and the Qt5Gui
Open depends.exe
Drag and drop the compiled application (in Release mode) of your project into the Depency Walker window
Copy DLLs that usually appear in yellow in depends.exe
(some are not absent, may be some error, such as an x64 DLLs in an x86 project)
Note that in Windows you need to copy a folder that is inside the "/ Qt / plugins" folder called platforms
and only one DLL is required (I believe), qwindows.dll
Getting something like (MingW):
./platforms/qwindows.dll (1mb)
./icudt53.dll (21mb)
./icuin53.dll (3mb)
./icuuc53.dll (2mb)
./libgcc_s_dw2-1.dll (118kb)
./libstdc++-6.dll (1mb)
./libwinpthread-1.dll (48kb)
./Qt5Core.dll (4mb)
./Qt5Gui.dll (5mb)
./Qt5Widgets.dll (6mb)
./app.exe
Disabling features
You can disable some features , such as OpenGL and ICU in Qt by setting the flag -no-icu
and -no-opengl
, to do this it is necessary to use configure.exe
, follow the link How to compile the static version of Qt for Windows with GCC (this link provides guidance on how to use configure.exe
to configure the desired options)
Other options you can try
-
-no-accessibility
Does not compile accessibility "Windows Active Accessibility"
-
-no-stl
Does not compile STL.
-
-no-sql-<driver>
Disables SQL entirely
-
-no-system-proxies
Disables system proxies
Using .LIB instead of .DLL
As colleague @Maniero said in this answer , maybe using .lib
might favor release end of the project
Do not limit yourself to Qt
There are other "SDKs" that are cross-platform , a good example is GTK +
A quick test-case (note that I compiled in C
, used GCC
, but you can compile in C++
using G++
)
-
main.c
#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Window");
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show(window);
gtk_main();
return 0;
}
To compile the command:
gcc -o app.exe *.c 'pkg-config --cflags --libs gtk+-3.0'
The only required DLL was zlib1.dll
, the result was 131kb:
./app.exe (48kb)
./zlib1.dll (83kb)