ccompilationbinary

making a binary as little as possible


I have a program written in C and linked to a my static library (.a) in C too. How can I make this program as little as possible, without touch the code (I can recompile it etc)?


Solution

  • The first hing is to strip it from everything like debug symbols, etc.

    On linux you can use in a terminal :

    strip myexe
    

    You will see the size greatly decrease ^^

    I'm no windows guru, but if you use VS, use the release variant.

    On every platform, do not use compiler flags that generate debug symbols. If you can use flags that optimize size.

    And of course, if you use system libraries or common installed libraries, use dynamically linked libs (dll) or shared objects (so). The libs will not be included in your executable.

    my2c