msys2/msys2.github.io

Large exe file on mingw for `Hello World!` program

iostream64 opened this issue · 0 comments

I installed mingw on my system to compile executable files for windows. The problem is the generated exe file is so large around 2-3mb. The same program on other compiler is about 100kb.

My program is just "Hello World".
``

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}

I use this code g++ main.cpp -static to compile my Hello World program.

And if I disable -static, this error shows

image

How can I make my compiled code small about 100-200kb?