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

好久不见. 提交于 2019-11-27 05:15:40

Flags to use:

  • -s like you've been doing to strip symbols
  • -lstdc++_s to specify dynamically linking against the libstdc++.dll
  • -Os to optimize the binary for size.

By default mingw static links to libstdc++.a on Windows.

Note that the lstdc++_s flag is only in MinGW with GCC > 4.4, I believe.

Give strip and UPX a try.

Using the -Os flag might help. That optimizes for size.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!