Home » Various » Setup Allegro tutorial part 1

Setup Allegro tutorial part 1

I haven’t seen any up-to-date Allegro 5 tutorial that focuses on learning via making games. All I found online were either small examples (like moving rectangle) about particular functions of Allegro 5, or complete guides for older versions. That’s why I decided to write down this small series of articles.
My goal is to teach various parts of Allegro gaming library, and basics of game programming concepts via making some – at first simple – game prototypes.
Tutorial assumes at least a basic knowledge of C/C++ programming, and although all examples were written and tested on Visual Studio 2010 under Windows 7 you can use any other IDE you like.

You can view code for this tutorial on github!

What is Allegro?
It’s cross-platform library aimed at video game programming, that can handle user input, loading data, audio and so on, although it supports only 2D graphics natively. You can use it to create games for the folowing platforms:

  • Windows (via MSVC, MinGW)
  • Linux/Unix
  • MacOS X
  • iPhone
  • Android (from 5.1 version).

How to setup Visual Studio project for Allegro?

Before we start making games we need to setup Visual Studio project to work with Allegro. We’ll work with stable relase for Windows, that you can download here.
To prove it works we’ll create simple hello-world app that creates blank window:


using std::cout;
using std::cin;

int main(int argc, char** argv)
		cout << "Something went wrong with allegro initialization!";
		return -1;
	window = al_create_display(300,400);
		cout << "Failed to create display :(";
		return -1;
	return 0;

But... oops. It doesn't work! Cannot open include file: "allegro5/allegro5.h" No such file or directory! Well it's natural we need to show our IDE where to find additional libraries.
We need to righ click project under Solution Explorer (by default it's on the right) and select Properties.
Now set:

  • Under Configuration Properties->C/C++->General->Additional Include Directories enter Y:\path\to\allegro\include path.
  • Under Configuration Properties->Linker->General->Additional Library Directores enter Y:\path\to\allegro\lib
  • Under Configuration Properties->Linker->Input append allegro-5.0.x-monolith-md-debug to Additional Dependences (where x is allegro version number. For this tutorial I used 5.0.6).

Now it'll compile but won't run!
You'll see nice error message about missing libraries. We need to set: PATH=Y:\path\to\allegro\bin;%PATH% under Configuration Properties->Debugging in Enviroment field.

Allegro getting started wiki article!

You can view code for this tutorial on github

Posted in Various and tagged as ,

Comments are closed.