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:

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:

MacOS (Sequoia 15.2):

Picture

iOS (18.2):

Picture

Linux (Ubuntu 24.04):

Picture

WebAssembly (emsdk 4.0.7):

Picture

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):

Picture

There are no separate “stripped” builds as the Android build process by default strips the binaries.

Windows (11, MSVC 2022):

Picture

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:

Picture

Then the smallest application, the simple app:

Picture

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:

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.


Blog Topics: