IMPORTANT NOTE: file size ≈ performance, so reduce file size ≈ reduce performance, so it's not recommended to reduce Qt binary file size.
-
Optimize for size instead of speed
call configure.bat -optimize-size
or change
qtbase\mkspecs\common\msvc-desktop.conf
QMAKE_CFLAGS_OPTIMIZE = -O1 -Os
-
Enable link time code generation
call configure.bat -ltcg
-
Disable RTTI
change
qtbase\mkspecs\common\msvc-desktop.conf
QMAKE_CXXFLAGS_RTTI_ON =
-
Use VC-LTL to reduce MSVCRT library size
-
Disable C/C++ exception
change
qtbase\mkspecs\common\msvc-desktop.conf
QMAKE_CXXFLAGS_STL_ON = QMAKE_CXXFLAGS_EXCEPTIONS_ON =
-
Use UPX to compress binary files
upx --best "*.dll"
or
upx --ultra-brute "*.dll"