The Allegro Wiki is migrating to github at

Build/Using precompiled binaries/MSVC

From Allegro Wiki
< Build‎ | Using precompiled binaries
Revision as of 15:49, January 30, 2010 by Japa Illo (talk | contribs) (Configure Project)
Jump to: navigation, search


Make sure you have to right version of MSVC

This guide and the binaries may work with other versions of MSVC, but that is unconfirmed. The version used for compiling and testing the binaries is MSVC 8 2009.

Install the DirectX SDK

Download the latest DirectX SDK from Microsoft and install it.

Download the Allegro binaries

Download the latest binaries from The ones for MSVC have MSVC in their filename.

You have two options.

First, you could extra the include and lib folders to C:\Program Files\<your msvc dir>\VC. This is the easiest, but the messiest way.

Second, you can create a folder in your home directory (for example C:\Users\billybob\allegro-4.9.16) and extract the include and lib folders there. This directory can be anywhere you like it.


Start up the IDE as normal. We'll now discuss creating a simple project.

Create the project

Go to File->New Project. Select Win32->Win32 Project and type a name for it then press enter. A wizard will come up. Hit next. Now you get a screen to customize the project. Simply select "Empty Project" Then click "Finish".

Right click on Source Files in the left hand pane. From the next dialog select C++ file, give it a name, and press enter. Click on the new file in the left pane and you can begin editing.

Example Project

Here is a very basic bit of code you can use to test your setup:

#include <allegro5/allegro.h>

int main(void)

    ALLEGRO_DISPLAY *display = al_create_display(640, 480);

    al_clear_to_color(al_map_rgb(0, 150, 0));



    return 0;

Copy and paste it into the editor.

Configure Project

Open your project properties now by going to Project-><your project name> Properties.

The next step is for those of you who extracted the include and lib files somewhere other than the MSVC default directories. Find Configuration Properties->C/C++->General. On the Additional Include Directories line, add the path to the include file you extracted. Now under Configuration Properties->Linker->General find the Additional Library Directories line and add the path to the lib folder you extracted. These two lines are the only difference between projects where you extra to your own folder or the MSVC default folder.

Still under project properties, go to Configuration Properties->Linker->Input. For every Allegro program you create, add this complete list to the Additional Dependencies line: kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib winmm.lib psapi.lib opengl32.lib dxguid.lib dinput8.lib d3d9.lib allegro-static-4.9.16.lib

If you use any Allegro addons, add them as well as their dependencies to this line. For example, if you use the image addon, add allegro_image-static-4.9.16.lib, png.lib, and jpeg.lib (also remember to include the allegro5/allegro_image.h header).

You will need to point Visual Studio at the DirectX SDK library directory; Configuration Properties -> Linker -> General -> Additional Library Directories

Lastly, under Configuration Properties->C/C++->Preprocessor, find the line "Preprocessor Definitions". Add ALLEGRO_STATICLINK to the list, without removing anything. Use a semi-colon (";") to separate the new definition from the others.

Compile and run

Now you can build and then run the project. You should get a 640x480 window with solid green in it displayed for 5 seconds. Wow. Now you're ready to make a program.