Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Optimizing executable file size
Optimizing executable file size [message #62085] |
Thu, 03 December 2026 09:59 |
frederik.dumarey
Messages: 40 Registered: December 2021 Location: Belgium
|
Member |
|
|
Hello all,
Recently I received a question from a friend Guan about the executable file size of a project made with theide in U++.
Since the answer can help other people out there, here is the analysis and the response from my experience:
- Normally the build method is set to CLANGx64 Debug mode: this means that all symbols, all headers are present in the executable. I my example I got an executable of roughly 7MB.
- You can easily change the build method to CLANGx64 release mode, just click on the dropdownbox next to the text field of the build method. Just click on compile (F7) and you will end up with an executable file without symbols and debugging information. In my case I got an executable file of 5MB.
But we can go further. As you can imagine not all headers, classes, and class members are used during the linking phase. Although the compiler makes object (.o) files off all c++ code, you main function won't use all of them. After some research, I found you can use this settings to further optimize the executable file size:
- Go to Setup ... Build Methods
- Duplicate CLANGx64 by right clicking
- Rename the build method to something "...size"
- Uncheck use BLITZ for release mode defaults
- Release options: -Os -ffunction-sections -fdata-sections -flto
- Release link options: -Wl,--gc-sections -flto
- click OK
To use the newly created build method, click left next to the text field indicating the build method, and choose it. Important: use rebuild all to compile and link. In my example I got an executable size of 1.9MB.
So an extra "compression" of 62% !
All comments welcome.
Regards,
Frederik Dumarey
Belgium
|
|
|
|
Goto Forum:
Current Time: Sat Dec 05 05:22:43 GMT+1 2026
Total time taken to generate the page: 0.00904 seconds
|