I'm working on an embedded processor so binary size matters a lot. I am trying to avoid using the standard library. I'd like to use std::function, however. I extracted "function.hpp" from boost, and I'm trying to use that, but simply including function.hpp increases the size of my binary 200k, which makes it bigger than my processor can accept. If I include the standard library, it only increases my binary 60k. I can't figure it out, if I'm not using any of the templates yet, there shouldn't be any overhead. And even if I do, I can't imagine it's 200k worth of code. I'm using gcc 4.7, and I've disabled debugging info from what I can tell "-g0" and turned on optimizations "-O2".
Any help would be much appreciated.
GCC includes some symbol information into the compiled binary even if you use -g0
. In order to really get rid of all symbols one should use --strip-all
command line option for the linker.
Also, since the size of the executable is important for you, consider -fdata-sections
and -ffunction-sections
for the compiler and --gc-sections
for the linker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With