The Allegro Wiki is migrating to github at

Windows, Code::Blocks and Allegro 5

From Allegro Wiki
Jump to: navigation, search

caption The images shown in this tutorial are for reference only caption Please note that you MUST install the matching compiler version with the version used to compile the Allegro libraries


To install Allegro with the pre-built binaries we need the Code::Blocks IDE, a MinGW installation, and Allegro binaries.

The compiler used to build allegro must be the same version as your compiler or else they will not work properly and you will get errors.

There are also unofficial builds which you can find here :

Unofficial MinGW Binaries

Note: While Code::Blocks comes with an embedded version of MinGW, it is recommended to use a standalone version such as the one linked above. This is for compatiblity reasons.

Allegro binaries and what to expect

Inside your binary distribution you should find three folders - \bin, \lib, and \include. \include is where all the allegro library headers are kept. \lib is where the archives that you link to are stored, and \bin is where the dynamic link libraries are kept. If you link dynamically you need these to be with your program at run time.


Configuring A New Project to use Allegro

Creating a New Project

  • Open Code::Blocks
  • In the menu, select File->New->Project
  • Select "Empty Project" and then "Go"


  • Enter a project title and a destination folder
  • Make sure "Create Debug configuration" and "Create Release configuration" are both selected


Creating a new file and adding it to your project

  • Select File > New > Empty File


  • Press "yes" to add the file to the current project.
  • Enter a name for the file and save it. As this example is using the c++ language, remember to end the file with ".cpp" instead of ".c".
  • Select "Debug" and "Release" configurations.


Setting project Search Directories

Now you need to add the allegro\include directory from the binary distribution to your compiler search directory. Go to Project->Build Options and select your overall project in the upper left. Then select the search directories tab on the right and then the compiler tab underneath it.


After that, go to the linker search directory tab and add allegro\lib to your search path.


Linking Allegro

Next, you need to update your linker settings to make your project link properly to allegro.

Most distributions of allegro come with a monolith version. That is what we'll be using here :

Make sure you match the names you are using with the names of your distribution's libraries. Dynamic versions generally end in .dll.a and static versions generally end in -static.a. Select the debugging or release versions as appropriate.

Dynamic Link


Static Link

When linking statically there are many more libraries that you need to link to.


Here is the full list of libraries :


That just about covers it for MinGW, Code::Blocks and Allegro. You do need to make sure \mingw\bin is on your %PATH% environment variable when you compile from the command line.