You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The executable size is 3.05MB compiled with g++ (gcc version 9.1.0 (Rev3, Built by MSYS2 project)). Such a overhead is insane for a simple program. It is even bigger than the "json.hpp" header file (711KB).
I roughly viewed through the source code. Class methods are mostly defined in class body, which will be inlined automatically. And a lot of macros and templates are used. All these facts probably cause the bloat of binary size.
Is there any advice for reduce object file size?
The text was updated successfully, but these errors were encountered:
I've just checked "-g" is used for including debug symbols, this truely contributes to the file size...
Removing that flag results in a smaller output (1.64M), it's still very big compared to 314KB for a empty main() function.
With "-O2" optimization flag, the size is reduced very much, 771KB compared to 313KB for empty main. This seems good enough. But I'm still in doubt whether file size will increase if more classes are compiled separately with serialization implementations in each class.
I tried your flags with both clang 8 on linux and mingw g++ 9 on windows, result in 113KB and 728KB respectively. "-O3" is possibly too much, it's known to have problem for certain cases.
Any way, hundreds of KB is good enough for most cases.
And I tried to compile more separate files, the size is not accumulated, some commonly used code might be reused.
Just tried to use some very basic features with following source code:
The executable size is 3.05MB compiled with g++ (gcc version 9.1.0 (Rev3, Built by MSYS2 project)). Such a overhead is insane for a simple program. It is even bigger than the "json.hpp" header file (711KB).
I roughly viewed through the source code. Class methods are mostly defined in class body, which will be inlined automatically. And a lot of macros and templates are used. All these facts probably cause the bloat of binary size.
Is there any advice for reduce object file size?
The text was updated successfully, but these errors were encountered: