nedelja, 30. november 2014

Installing Allegro 5 for Game Development

This article will cover how to install the Allegro 5 game library on Windows. Installing on Linux should also be fairly easy, since Allegro is included in the depositories of most package managers. 

For most purposes, downloading the binary release of Allegro is preferable to compiling the library yourself, especially on Windows. Downloads for these files can be found on the Allegro.cc Files page. You'll notice that there are several downloads available, depending on whether you are using MinGW or MSVC. If you are using MinGW, you can find out which version you are using by typing gcc --version in the command prompt.

I recommend reading the short (but sweet) installation guide for Windows. Basically, what it says is that Allegro is a modular library. That means that you can decide which modules to use and which to leave out. For example, you may not need the native dialog functionality or maybe you don't need TTF font support in your game... No problem! Allegro is compromised of the following modules:


  • allegro - the core library
  • allegro_main - allows the use of int main() on all platforms.
  • allegro_acodec - audio codecs
  • allegro_audio - basic audio functionality
  • allegro_color - allows converting between different color formats
  • allegro_dialog - native dialog support
  • allegro_font - basic bitmap fonts
  • allegro_image - support for various image formats (JPG, PNG)
  • allegro_memfile - interface for loading files from memory
  • allegro_physfs - allows loading files from archives (zip files!)
  • allegro_primitives - basic primitive drawing
  • allegro_ttf - TTF support

Obviously you'll always link with the 'allegro' core library, but besides that, everything else is pretty much optional. Depending on what type of game you're building, you could include either all of these libraries or merely a few.

Just use the monolith version

Personally I never bothered with cherry picking only the libraries I need. For me, the monolith version wins because of two reasons:

  1. Only one DLL file
    If you use the monolith version, that means you have to distribute only one extra DLL file for Allegro to work. I like this because it makes things more simple. The size itself is no concern, the monolith DLL barely adds 4 MB to the total size. For some this might be a lot, but I doubt it's relevant to most people.
  2. It Just Works
    Just link the monolith-mt version of the library and you're all set to go. That's it. 

MT vs MD

It's already explained in the installation guide but adding it here wont hurt. The MT version has the includes the standard C library as part of the executable, the MD version doesn't, so with that version you'll have to link and provided the appropriate system DLL's. Just use the MT version if you are unsure.

Linking and Testing

int main (int argc, char *argv[])
{
    return 0;
}