Reducing Binary Size of Qt Applications – Part 3: More Platforms (original) (raw)
June 09, 2025 by Juha Vuolle | Comments
Optimizing Qt builds on macOS, iOS, Windows, Android, WebAssembly, and Linux.
In Part 1 we introduced the Qt size optimization guide. Part 2 presented a concrete example on Raspberry Pi (Linux).
Linux is one of the many platforms supported by Qt – but what about optimizing size on the other platforms? Some configure options are platform dependent, and they don’t always transfer from one platform to the other.
In this blog post, we’ll take a look at the other platforms. The main objective is to provide reference feature sets that can be used as a starting point for your own configurations.
Reference Applications
When creating a minimal Qt configuration, you need to decide what should still work. The better you know, the more you can reduce unnecessary features or make acceptable performance or security tradeoffs. For this purpose, we selected a handful of Quick example applications that should work with the configuration:
- Coffeemachine - for comparison with previous blog
- Colorpalette Client - uses networking and https
- Gallery - uses most Qt Quick Controls
- Calqlatr
- Simple application - minimalistic reference application that consists of a QML Window and Text element (a “hello world”).
Platforms
We tested the configurations on these six platforms:
The codebase was a recent Qt dev
branch (upcoming Qt 6.10). Most of the fixes needed for the minimal configurations to compile have also been picked back to Qt 6.9 and Qt 6.8.
Results
The resulting configurations are best summarized by the CI configuration. The configurations on different platforms share most options but have their differences, too.
Notably, most of the builds are static builds. A static build means that the application, Qt libraries, and Qt plugins are all compiled into a single executable. Static builds allow the compiler and linker to make powerful size optimizations as they can see the whole binary. Android is the exception as Qt for Android doesn’t support static builds at the moment.
The charts below show the storage size for each application. Legend:
- Reference: release application with default configuration
- Reference stripped: reference application whose symbols are stripped
- Minimal: application built with the minimal configuration
- Minimal stripped: minimal application whose symbols are stripped
MacOS (Sequoia 15.2):
iOS (18.2):
Linux (Ubuntu 24.04):
WebAssembly (emsdk 4.0.7):
Notably the WebAssembly configuration uses LTO linker flags directly because the -ltcg
option provided by Qt configure hits a compiler bug. That bug has been fixed recently so in the future you can use the ltcg
option also on that platform.
Android (NDK 26.6.1):
There are no separate “stripped” builds as the Android build process by default strips the binaries.
Windows (11, MSVC 2022):
On Windows there are no separate stripped versions as stripping does not seem to be used or needed with MSVC (unlike with MinGW).
Side-by-side:
Let’s also have a look at the application sizes per platform, side-by-side. First the biggest application, Colorpalette:
Then the smallest application, the simple app:
On all platforms, size optimizations have a significant impact. Perhaps unsurprisingly, macOS and iOS sizes are almost identical. Android .apk is the largest in size. This is likely due to lack of static building support, and the bundling (androiddeployqt
) may deploy more components than needed. Fortunately, the latter can be tuned manually, see this blog post.
Further Optimizations
We chose the minimal configuration such that the selected reference applications still work. But real production applications have specific needs and can be optimized further. Here are some examples:
- Disable networking if your application doesn’t need it (also good for security)
- Disable all quickcontrols2-styles if not needed. Don’t build them and more importantly don’t import them.
- Disable more image formats – for instance, SVG support is clearly visible on the binary size breakdown
- Disable settings if not needed – settings are also quite clearly visible on the binary size breakdown
And much more. Many features like shortcuts
support remain in the minimal configuration because the reference applications use them – but maybe your application doesn’t.
I Disabled a Feature and Now Qt Doesn’t Compile
The configurations presented here required several small code fixes to compile. This is somewhat understandable as it’s not pragmatic to compile all possible feature combinations (theoretically speaking, there are more feature combinations than there are atoms in the visible universe).
Luckily, the fixes needed are typically quite small and trivial. When you configure non-standard feature sets and encounter issues with something you think should work, please file a report at Qt Bug Tracker or submit a patch.
Conclusion
Feature selection and build flags can greatly impact the size of the Qt libraries and applications. The better the application needs are known, the more can be optimized. The minimal configuration presented here can work as a good starting point for your own minimized configuration.
It should be noted that a size-minimized application is, however, not ideal for development time. At development time you should have the tools and symbols needed available. Furthermore, compiling applications statically with link-time code generation is slower than making a shared build.