From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32681 invoked by alias); 25 Sep 2004 19:37:51 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 32661 invoked from network); 25 Sep 2004 19:37:50 -0000 Received: from unknown (HELO main.gmane.org) (80.91.229.2) by sourceware.org with SMTP; 25 Sep 2004 19:37:50 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CBIMf-0003w2-00 for ; Sat, 25 Sep 2004 21:37:49 +0200 Received: from 12-219-2-179.client.mchsi.com ([12.219.2.179]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 25 Sep 2004 21:37:49 +0200 Received: from puetzk by 12-219-2-179.client.mchsi.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 25 Sep 2004 21:37:49 +0200 To: gcc@gcc.gnu.org From: Kevin Puetz Subject: Re: Reducing the size of the binaries Date: Sat, 25 Sep 2004 21:51:00 -0000 Message-ID: References: <20040925175040.GA67405@cs.huji.ac.il> <20040925190401.87589.qmail@web53210.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8Bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 12-219-2-179.client.mchsi.com User-Agent: KNode/0.8.0 X-SW-Source: 2004-09/txt/msg01496.txt.bz2 Juan Ignacio Garzón wrote: > Hi i'm compiling a very simple program that consists > in 3 files: > -a .h file (20 lines of code), which declares a class > and includes iostream > -a .cpp file (33 lines of code), including only the .h > file. > -main.cpp (11 lines), which includes only the .h. > > So, as you can see, its a very very simple program > with 1 class and a main. I'm just beginning a proyect. > When I compiled this using the following command line: > g++.exe -c ... -o ... -I ... -DDEBUG -Wall -pedantic > -g -ansi -fno-inline -g is a request for debug symbols. These are huge, because you when you #include iostream, debug symbols for your application involves the debug symbols for a pretty fair chunk of the templates in libstdc++ :-) > the result was: > a .o file for the main.cpp (803 KB) > a .o file for the .cpp (class definition) ( 810 KB) > the .exe file (1251 KB) > > I'm using gcc 3.2 (mingw32) > I cannot understand why are they so big in size... I > think im doing something bad, but I don't know what... > > If I include stdlib.h in any file, it results in a 2 > MB exe. > I have a lot of programs made with C++ and their > binaries are smaller than mine, and mi program has > less than 100 lines. What's wrong? They don't have debug symbols turned on (in fact, if you're looking at release stuff, they probably have been run through 'strip' and don't have any symbols at all except those needed to resolve linkage to DLLs). Also note that at -O0 (the default, no optimization) binaries are likely to be larger and slower than at -O1 (quick optimizations, don't slow the build down too much), -Os (specifically optimize for size), or -O2 (optimize for speed, most often used). -O0 mode is rather naive in it's code generation, and is usually either to make the compile go fast or to make the code easy for a debugger to follow. > Thanks in advance... > > > > > > > ___________________________________________________________ > 100mb gratis, Antivirus y Antispam > Correo Yahoo!, el mejor correo web del mundo > http://correo.yahoo.com.ar