How to reduce the size of executable produced by MinGW g++ compiler?

后端 未结 4 798
情书的邮戳
情书的邮戳 2020-11-30 11:07

I have a trivial \"Hello world\" C++ program that is compiled to 500kB executable by MinGW g++ compiler under Win XP. Some say that is caused by iostream li

4条回答
  •  误落风尘
    2020-11-30 11:31

    You should be using -O for optimization. Add "-O{level}" to your compiler args and it will optimize for either speed or size. Check the docs for your compiler.

    You could also have debugging symbols enabled. Stripping those will also make it smaller.

提交回复
热议问题