From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin von Loewis To: alex.buell@tahallah.demon.co.uk Cc: egcs@cygnus.com Subject: Re: Oddities with gcc/g++ linkage Date: Sun, 20 Sep 1998 17:05:00 -0000 Message-id: <199809201937.VAA13649@mira.isdn.cs.tu-berlin.de> References: X-SW-Source: 1998-09/msg01175.html [g++] > On my machine that gives a binary executable size of 44k! [gcc] > On my machine this gives me a binary executable size of 3k!! [...] > Can anyone explain such variances in binary size? I get the same results, probably because I'm using the same configuration (i386-pc-linux-gnu). To investigate, I run g++ -o a a.cc -v --save-temps This tells me that input, preprocessor output, assembler code, and object file are about the same size in both cases. So it must be the linking. Therefore, I run g++ -o a a.cc -Wl,--verbose (assuming a GNU linker). The difference becomes quite clear, now: libstdc++ is linked as well. ld takes the objects stdstrbufs.o streambuf.o filebuf.o stdstreams.o from this library, and needs some more libgcc objects in turn. I'm not entirely sure *why* this is happening. I believe it is a libio feature, where libio comes from libstdc++ in this case, instead of libc. Adding -lc doesn't help, because libstdc++ is searched first. Regards, Martin