Pelles C forum

C language => Windows questions => Topic started by: ly47 on June 20, 2014, 06:13:39 PM

Title: EXE size ?
Post by: ly47 on June 20, 2014, 06:13:39 PM
Hi
I have compiled several progs with:
Pellesc and tcc to see exe size results.
(console simple "hello" prog and for win32 a chapter 7 (Checker1) from Petzold book)
So far:
tcc produce      1.50 kb (console) and 4.00 kb (win)
pelles pruduce  29.0 kb (console) and 10.5 kb (win).

I have tried same console  progs to run with assembly:
masm32 and rosasm produce 2.50 kb.

Conclusion: tcc produce the smallest exe.

Can somebody explain the diff. ?

Thanks
ly
Title: Re: EXE size ?
Post by: frankie on June 20, 2014, 08:50:08 PM
The user code in an exe file, for very simple programs, is few hundreds of bytes, the remaining is taken by startup code, the crt code, and PE-COFF file structure (a couple of hundred of bytes for headers, 8-16 bytes per each relocation in DLL's).
You can reduce the exe in two principal ways: linking with the DLL runtime, or use a simplified (and smaller) c runtime.
Read here (http://forum.pellesc.de/index.php?topic=88.0) for an example of reduced runtime for PellesC, or here (http://www.catch22.net/tuts/reducing-executable-size) for an article on the subject from catch22.
Title: Re: EXE size ?
Post by: ly47 on June 20, 2014, 10:18:44 PM
Hi frankie
Thanks.
Very interesting info.
ly