Mail Archives: djgpp/1996/06/09/10:10:46
On 7 Jun 1996, Martin Krieger wrote:
>
> #include <iostream.h>
> int main()
> {
> cout << "Hallo, Welt!\n";
> }
>
> compiles to
>
> TEST.EXE 158.101 07.06.96 23:21
>
> Why is this nice little program so extremly huge? Is there a way to shrink
> it? (Any plans for optimizing linkers like that one Borland Pascal has?)
Are you *really* interested in the size of a toy program like that? Most
of the overhead is *additive*, so it stays almost constant for much
larger programs. In other words, a 1MB-long program also gets a few tens
of KB as an overhead of the startup code and the low-level library
functions.
As to the ways to reduce the size, there are some. First, compile with
-O2 (makes code smaller) and link with -s (strips the debugging symbols).
Second, for programs that don't need command-line expansion and filename
globbing, you can define a few library functions with empty bodies and
slash about 18KB; this described in the library reference (search for
"_crt0_").
- Raw text -