delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/09/10:10:46

Date: Sun, 9 Jun 1996 16:59:30 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: j4139208 AT athena DOT rrz DOT uni-koeln DOT de
Cc: djgpp AT delorie DOT com
Subject: Re: Why are they so fat?
In-Reply-To: <4pa8al$2pd@news.rrz.uni-koeln.de>
Message-Id: <Pine.SUN.3.91.960609165200.342V-100000@is>
Mime-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019