Contents Up << >>

Why is my executable so large?

Many people are surprised by how big executables are, especially if the source code is trivial. For example, a simple "hello world" program can generate an executable that is larger than most people expect (40+K bytes).

One reason executables can be large is that portions of the C++ runtime library gets linked with your program. How much gets linked in depends on how much of it you are using, and on how the implementor split up the library into pieces. For example, the iostream library is quite large, and consists of numerous classes and virtual functions. Using any part of it might pull in nearly all of the iostream code as a result of the interdependencies.

You might be able to make your program smaller by using a dynamically-linked version of the library instead of the static version.

You have to consult your compiler manuals or the vendor's technical support for a more detailed answer.

  • Nuances of particular implementations