#include <stdio.h>
int main(void);
int main(void) {
printf("hello world\n");
return 0;
}
Originally, lcc-win32 builds an exe of 100kb! I found out how to get
the exe size down to 31kb by unchecking the Compiler > Generate debug
info under Project Configuration, but 31kb is almost twice the size of
the exact same code under WinGW, which builds an exe of only 16kb.
Is this a result of a completely different stdio.h file?
Are there any other optimizations or settings that I can do under lcc-
win32 to get the filesize down to a more respectable size?
Thanks!
I don't know about switches for lcc.exe. If you link separately with
lcclnk.exe you can use:
lcclnk -dynamic -S -o hello.exe hello.obj
for example, to reduce the size. Your example reduced to about 3600 bytes.
--
Bart
That does reduce the filesize significantly, but the application will
fail on installations where the lcclib.dll is not present. Not quite
the solution I was looking for as I would like the application to be
self contained.
That is 13K
printf is a big function, but with Mingw it is stored in the
dll crtdll.dll. If you would count the size
of that dll, the program woukd make 100K.
I do not use that dll any more since it has too many bugs!
The executables of lcc-win are still smaller than Mingws!
>>> #include <stdio.h>
>>
>>> int main(void);
>>
>>> int main(void) {
>>> printf("hello world\n");
>>
>>> return 0;
>>> }
>>
>>> Originally, lcc-win32 builds an exe of 100kb! I found out how to get
>>> the exe size down to 31kb by unchecking the Compiler > Generate
>>> debug info under Project Configuration, but 31kb is almost twice
>>> the size of the exact same code under WinGW, which builds an exe of
>>> only 16kb.
>>
>>> Is this a result of a completely different stdio.h file?
>>> Are there any other optimizations or settings that I can do under
>>> lcc- win32 to get the filesize down to a more respectable size?
>>
>> I don't know about switches for lcc.exe. If you link separately with
>> lcclnk.exe you can use:
>>
>> lcclnk -dynamic -S -o hello.exe hello.obj
>>
>> for example, to reduce the size. Your example reduced to about 3600
>> bytes.
> That does reduce the filesize significantly, but the application will
> fail on installations where the lcclib.dll is not present. Not quite
> the solution I was looking for as I would like the application to be
> self contained.
You mean you want the C runtime functions to be statically linked? I don't
know how you'd get it below 30KB, maybe the lcc versions just happen to be
more extensive.
The -dynamic flag means the runtime functions are loaded from a DLL, and
Windows comes with such a DLL, msvcrt.dll for example. However trying to
include \lcc\lib\msvcrt.lib in the linker files didn't work; there still
seems to be something it needs from lcclibc.dll. I think we need some proper
lcc experts here...
--
Bart
Well, the best thing to do is to accept those 31K in the disk file.
Note that RAM usage IS THE SAME, since the dll will use printf anyway
and will take address space for it, probably around 30Kb too!
In thgis days of TERA BYTE disks, complaining about 30K more disk space
looks difficult to understand for me.
In My reply to the original poster, I hinted that using puts() will make
the executablme much smaller than MINGW's size: 3500 bytes only!
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jacob, you are absolutely right! It is considerably smaller to use puts
(). Once I'm finished the full application, I'll compare filesizes and
speeds between compilers just for fun, but it looks like it is
dependent on which libraries the different compilers use for the
programmer's functions. Thanks for your reply and thanks so much for
the wonderful software! The documentation is incredible too, it's
quite possibly the best book I've read on the C language.