Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my C++ executable so big? [duplicate]

Tags:

c++

size

Possible Duplicate:
GCC C++ “Hello World” program -> .exe is 500kb big when compiled on Windows. How can I reduce its size?

I've just started reading some C++ online tutorials and the first lesson was the Hello World program. When I compile the program to an executable, the size is over 400kb even though it's just a simple Hello World console program. Should it be this big? If not, why is it happening? Am I doing something wrong?

Here is the source:

#include <iostream>
using namespace std;
int main()
{
    cout<<"Hello World";
    cin.get();
}

Any help would really be appreciated. Thanks

like image 633
user1449029 Avatar asked Aug 04 '26 21:08

user1449029


1 Answers

Statically linking the C and/or C++ runtime can greatly increase the size. Also, compiling your program to include debugging information can increase the size.

like image 120
flumpb Avatar answered Aug 07 '26 12:08

flumpb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!