Including boost function.hpp, without using it, it increases the size of my binary file by 200 thousand. Why?

I am working on an embedded processor, so binary size matters a lot. I try to avoid using the standard library. However, I would like to use the std :: function. I have extracted "function.hpp" from boost, and I am trying to use it, but just by turning on the function. Hpp increases the size of my binary 200k, which makes it larger than my processor can accept. If I include the standard library, it will only increase my binary 60k. I can’t understand, if I’m not using any of the templates yet, there should be no overhead. And even if I do, I can’t imagine a code that costs 200 thousand. I use gcc 4.7, and I turned off debugging information from what I can say β€œ-g0”, and turned on the optimization β€œ-O2”.

Any help would be greatly appreciated.

+8
c ++ gcc boost std embedded
source share
1 answer

GCC contains some information about the characters in the compiled binary, even if you use -g0 . To really get rid of all the characters, use the --strip-all command line --strip-all for the linker.

Also, since the size of the executable is important to you, consider -fdata-sections and -ffunction-sections for the compiler and --gc-sections for the linker.

+2
source share

All Articles