Customizing the ICU
The Dlls of ICU really are heavy, mainly the icudt5*.dll
But there is a way to customize this DLL using the ICU Data Library Customizer, thus being possible to greatly reduce its size, as mentioned in qt forum
Reduced examples:
Using the Dependency Walker
One feature you can use to detect the necessary Dlls in your project is Dependency Walker, it will help you detect only the necessary dlls, using:
- The most important thing first of all is that you should rename the folder
/Qt/QtX.X.X
for something like /Qt/QtX.X.X-tmp
, because some Dlls may be "registered"
- Initially the folder with your EXE must not have any DLL except the
Qt5Core
and the Qt5Gui
- Open the
depends.exe
- Drag and drop the compiled application (in Release mode) from your project into the "Depency Walker) window"
- Copy Dlls that usually appear in yellow on
depends.exe
(some are not absence, may be some error, such as a Dlls for x64 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 resources
You can disable some resources, like Opengl and ICU in Qt flag -no-icu
and -no-opengl
, to do this it is necessary to use the configure.exe
, follows the link How to compile static version of Qt for Windows with GCC (this link provides guidance on how to use the configure.exe
to configure the desired options)
Other options you can try
-no-accessibility
Do not compile accessibility "Windows Active Accessibility"
-no-stl
Do not compile STL.
-no-sql-<driver>
Disables SQL entirely
-no-system-proxies
Disables the system proxies
Using . LIB instead of . DLL
As Mr @Maniero said in this answer, maybe use .lib
may favor in size release end of the project
Don’t limit yourself to Qt
There are other "Sdks" that are cross-Platform, a good example is GTK+
A quick one test-case (note that I have compiled in C
, used GCC
, but you can compile in C++
using the 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 DLL required was the zlib1.dll
, the result was 131kb:
./app.exe (48kb)
./zlib1.dll (83kb)
Gabriel only debug Dlls weigh, release Dlls are much lighter
– Guilherme Nascimento
Still, it reaches more than 40 Mb.
– Gabriel Sales
Unfortunately yes, in most cases the size of your project will get 100mb, compressed with 7z (to create an installer) should get about 33mb. Nowadays it is difficult to have software with less than 100mb installed.
– Guilherme Nascimento
The problem is that it is an application with nothing, only a form(Qt) and a header(1kb). In visual studio, this would be around 4mb, with libraries.
– Gabriel Sales
Gabriel talevz has copying dll the most, please try my answer... Merry Christmas (I don’t even celebrate it rs)
– Guilherme Nascimento
If I understand what you call link static. You cannot do this without purchasing the commercial license. Technically it is possible but it is not legal. I think it’s an exaggeration the 100MB @Guilhermenascimento spoke about (not that it’s not possible all this size) but don’t expect a GUI application to be less than a few megabytes, linked statically or dynamically. In fact I confirm that from what I imagine you are doing, that is, very simple tests, if you are using more than 2 or 3 Dlls, I think there is something wrong.
– Maniero
@bigown I agree, I really exaggerated, is that it’s been kind of hard to see applications with less than 20mb, really it was a mistake of mine, but with QT I could not get less than 40mb (at least with Mingw). Thank you for the information on the link.
– Guilherme Nascimento
Any Hello World in Gui will stick with some MB. Indeed link statically can decrease the size a little (I’m talking about this in that reply, but it seems that few people understand this) but do not expect miracles mainly because Qt has many dependencies and the form of the compilation also may not help much.
– Maniero
@bigown I’m reading, I think I’m beginning to understand, I’ll study. Thank you for this reply. I edited the reply and put a reference to your link. Thanks again! Merry Christmas
– Guilherme Nascimento
The distribution using Qt really gets big without static linkage, but your program will work standalone, using other frameworks like . NET or the Java libraries they become small but because the user already has the libraries on his computer. You can use the UPX to try to reduce the size of the final binaries.
– Cahe
You don’t need all the Dlls, only the ones you actually use in your application. I’m finding this amount of data that you mention too exaggerated, I’ve never been able to reach even halfway with full application distribution in Qt.
– Bacco