Date: Sun, 9 Jun 1996 16:59:30 +0200 (IST) From: Eli Zaretskii 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: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On 7 Jun 1996, Martin Krieger wrote: > > #include > 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_").