Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Building qmake: Reducing Application File Size



  • Hello,

    I am developing a QtQuick Application with C++ backend that is targeting an embedded linux device using a STM32MP157 MPU. Upon production release, I'm limited to upgrading my application via a UART file transfer, so I want to reduce my application file size as much as possible.

    I am currently developing on a Windows 10 Host using a VirtualBox Ubuntu 18.04 Guest VM. I built qmake for my target from source to target Qt 5.14.2, which is the latest version my STM32MP157 OpenSTLinux Distribution targets. (I know there are future updates for that distribution, but that's the one I'm locked to for now). When I use this qmake to build my application, the resulting output file is ~6MB.

    I was previously developing on a Windows 10 Host using a VirtualBox Debian Guest VM provided by another display provider, DLOGIC, that had already built a qmake for an embedded target with Qt 5.9.x. This qmake built images that were also able to run on my STM32MP157 MPU. When I use this qmake to build my application (same source /project files as above), the resulting output file is ~2MB.

    I compared the two qmake.config files from the different qmake builds and cannot figure out what has been changed in my Qt 5.14.2 qmake build that is making my output file bloat ~4MB. Can anyone provide some assistance? I feel like it's an obvious command line argument I've overlooked and a new set of eyes will see it. Both qmake.config files are attached.

    Thank you for your time

    Ubuntu_6MB_qmake.png Debian_2MB_qmake.png


  • Lifetime Qt Champion

    I would guess the additional file size comes from the included debug symbols. Try to e.g. strip them to see if the file size goes down to 2MB


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Beside the check @Christian-Ehrlicher suggested. If you want to minimize the size of you executable, one other thing you can do is build a custom version of Qt with all that you do not use disabled. For example the regular expression stuff, the model view, etc. It takes some patience but can drastically reduce your memory footprint.



  • Thank you both for the suggestions! I ran /usr/bin/arm-linux-gnueabihf-strip on one and it reduced it from a size of 6468168 to 6262788, so a reduction of ~0.2MB.

    I didn't realize removing the modules I selected for my qmake would change my application output size - I assumed if I wasn't using those modules they wouldn't be built into my resulting binary file. I will try this and report any findings.


Log in to reply