Reducing your executable size

Some people complain that Allegro produces very large executables. This is certainly true: a simple "hello world" program will be about 200k. But don't worry, it is a relatively fixed overhead and won't increase as your program gets larger. As George Foot so succinctly put it, anyone who is concerned about the ratio between library and program code should just get to work and write more program code to catch up :-)

Having said that, there are several things you can do to make your programs smaller:

If you are distributing a copy of the setup program along with your game, you may be able to get a dramatic size reduction by merging the setup code into your main program, so that only one copy of the Allegro routines will need to be linked. To do this, rename the main() function from setup.c to something like setup_main(), link setup.c and setupdat.s into your program, and add a switch (eg. -setup command line option) that will call setup_main() instead of your main program code. After compressing the executable, this will probably save you about 200k compared to having two separate programs for the setup and the game itself.




Back to Contents