Mail Archives: djgpp/1997/05/18/14:17:11
Richard Collins (rcollins AT hermes DOT otago DOT ac DOT nz) wrote:
: Which worked well, but I was shocked to see the program was about 80k.
: So I tried:
: Main(){}
: Which compiled to 60k.
: I tried the equivilent programs in turbo pascal, and got 2.4k and 1.6k
: respectivly.
Do the same thing using debug, writing it in assembler; you'll only need a
couple of bytes :)
The point is, there is a certain amount of startup code which gets added
to all your programs. It performs several functions, including looking for
a DPMI host, loading CWSDPMI if it can't find one, globbing the
command-line, switching to protected mode and starting your actual program
code. For these short programs it is pretty useless; you don't need
protected mode to just do nothing; nor do you need therefore a DPMI
server, a stub, command-line globbing, etc.
If you write longer programs, you shouldn't see so much difference between
executable sizes in DJGPP and other environments, relative to the size of
the executable. The second thing you should try is stripping the debugging
information out of the executables. By default, gcc puts a certain amount
in, and if you specify -g it puts a great deal more in. Specifying -s, or
running strip on the executable, will remove all this debugging
information.
This isn't actually the problem with the above code, since there isn't
really much debugging information to strip, but when you write longer
programs bear this in mind. I would suggest using -g during the
development stage, and only stripping the information before distributing
your programs.
--
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford
- Raw text -