Executable size is very big

1k views Asked by At
#include <iostream>

int main() {
    std::cout << "HI";
}

this is the code. after compiling it is 220kb.
I used this command : cl /EHsc main.cpp.
help me reduce the size

1

There are 1 answers

1
BoP On

You can get a huge difference by not linking statically to the runtime. In addition to the optimization flags, use /MD to use the runtime DLL.

I get the .exe size down to 11 kB.

And even if you do

#include <iostream>

int main() {
    std::cout << "HI";
    std::cout << "HI";
    std::cout << "HI";
    std::cout << "HI";
}

it is still 11 kB, so it is not growing by 220 kB per source line. :-)