Reducing size of executable in mingw/gcc

I was compiling some basic codes in qt. I observed that even for a hello world project , it is taking close to 1 mb , even in release mode. So did a google search on that. Found that main culprits are

  • Included debuging info.
  • included standard libraries.
  • RTTI , EXCEPTION handling, usage of templates.

In my case, usage of templates is the main reason. Seems like compiler loves to generate different codes for each template instances. Eg. vector<int> and vector<string> will have different implementation.

Solution is to disable the above mentioned features using some compiler options


For complete list of options check this. You may also consider packing your executable using UPX.

Leave a Reply

Your email address will not be published. Required fields are marked *