c++iostream

Why just including <iostream> makes executable weigh 1mb more?


It is not even a "hello world", it is simply:

#include <iostream>

int main()
{
    return 0;
}

which weighs 1080 kb. When I remove the iostream inclusion in the program to get:

int main()
{
    return 0;
}

the executable's size becomes only 49 kb.

I just want to include iostream and maybe use only std::cout, but the size will be the whole megabyte again. So, where is the trouble and how can I fix it?

I am using wxDevCpp with mingW and debugging info feature is off.


Solution

  • So, where is the trouble and how do I fix it?

    Including <iostream> instantiates the global variables std::cout, std::cin and std::cerr, and thus links in the whole c++ I/O library.

    The only way to fix this, is not including <iostream>, if you don't need anything from there.