Compiler: Size of generated executable file

Walter Bright newshound1 at digitalmars.com
Tue Jan 12 13:35:32 PST 2010


retard wrote:
> That still doesn't explain why the resulting binaries from the two 
> examples have so big a difference in size. When I compile them with gcc 
> 4.4.3, the non-stripped non-optimized binaries are 6994 and 6427 bytes. 
> Stripped and -Os optimized ones are 4504 and 4264 bytes. So the extra 
> functions cost 240 bytes while your compiler generates 10 kB of 
> additional data. The printf is linked in statically? Is this some windows 
> related limitation?

As I mentioned in another thread, gcc does not link in the C runtime 
library. The library is a shared library (or dll), which is not part of 
the exe file, though it is part of your running program. dmc links in 
the C runtime library statically, thus avoiding dll hell.

I'll reiterate that this is easily discoverable by looking at the map 
file. Just looking at the exe file size and blindly guessing what is 
consuming space in it without looking at the map file is a waste of time.




More information about the Digitalmars-d mailing list