Menu

exe size

Compiling
zeulb
2012-12-09
2013-09-19
  • zeulb

    zeulb - 2012-12-09

    when i compile hello world program, the exe file really large ~5MB anyway to optimize this ?

     
    • Ad van Gerwen

      Ad van Gerwen - 2012-12-10

      See my post in file-size.

      Sorry for the extra topic.
      I am new in this forum and discovered NO possibility to reply
      an existing topic.
      After initiating the new topic I got the reply-buttons visible in all posts. Strange !!!!

       

      Last edit: Ad van Gerwen 2012-12-10
  • orwelldevcpp

    orwelldevcpp - 2012-12-09

    You could blame the C++ headers and libraries for being a bit on the fat side, but complaints like that aside, there are quite a few ways to fix this:

    • You can remove any unused header information from exes using the -s command. It can be found under Tools >> Compiler Options >> Settings >> Linker for non-project compilations and Project >> Project Options >> Compiler >> Linker for project compilations. This is the most effective measure. Beware that debugging information is stripped too, so you won't be able to debug your program.
    • Using C headers instead of C++ ones will help a great deal too, but I understand that's usually not an option.
    • You can tell the compiler to optimize the assembly for size, by using -Os. Please check the 'Optimization Level' option for this.
    • You can decide to dynamically link library data by removing '-static-libgcc' and the other -static flag from Tools >> Compiler Options >> General. This will shrink the exe, but you will be forced to provide DLLs when you need to run your exes.

    I hope I could be of help.

     
  • MikeDNC

    MikeDNC - 2013-09-19

    Also, here's a Makefile that will automatically run UPX (Ultimate Packer for eXecutables after your Dev-C++ Project is built.. can reduce size by an additional 70%+.

    To use, add to
    Project|Project Options|Makefile|Include the following files into Makefile.

     

    Last edit: MikeDNC 2013-09-19

Log in to post a comment.