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

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.

Leave a Comment