|
From: Per W. <pw...@ia...> - 2007-02-13 15:54:42
|
If I just copy your code to test_size.cpp and then do:
g++ test_size.cpp
on your source, I get a binary that is 475kB.
If I strip the binary, it will shrink to 266kB.
This with MinGW gcc 3.4.2.
Alas, the c++ library is quite aggresive at adding stuff to hello-world
applications. The good part is of course that when you do add real code to
the project, a large part of the RTL is already included, so the binary
will not continue to grow at the same high speed.
/Per W
On Tue, 13 Feb 2007, Philip Bennefall wrote:
> Hey folks,
>
> I've been feeling for a while that my executables have been much larger than they need to be, so I tried to make a very simple console application in C++ using iostream and nothing more. This code generates an executable that is over 400 kb!
>
> ---Code begin---
> #include <iostream>
>
> using namespace std;
>
> int main()
> {
> int year;
> cout << "How old are you?\n";
> cin >> year;
> cout << "Okay, you are " << year <<" years old.\n";
> fflush(stdin);
> getchar();
> }
> ---Code end---
>
> This, I should imagine, would be something like 20 kb. I looked in the FAQ of course, and it said that I should make sure that I don't have debugging enabled. It does not look like it is, and I just can't figure out why the files are so huge. iostream, that's really small. Can anyone help? I have not modified any settings in compiler options at all.
>
> Regards
> Philip Bennefall
|