Setting up Allegro-4.2.2 in Visual C++ 08

By csfinch

     I have found a couple of people on www.gamedev.net having trouble installing Allegro in/using Visual C++ 2008 “Orcas” and since for some reason I have found an easy way of installing it I’ve decided to showcase a small article on how I installed the Allegro-4.2.2 library and having it accessible in Visual C++ 2008.

First the link to the Allegro-4.2.2 library can be found here Allegro-4.2.2 . Now let’s get through some easy quick instructions.

 

Installing Allegro-4.2.2 correctly on your system

  1. Unrar the folder Place this in a safe folder that you know won’t get deleted, or shifted around
  2. Start up Visual C++ 2008
  3. Direct yourself to Tools > Options
  4. Under Options > Projects and Solutions > VC++ Directories
  5. Direct yourself to “Show Directories for:” in the combo box look for inlcude
  6. Create new line click on the browse button and direct yourself to the allegro-4.2.2 \include directory
  7. direct yourself to “Show Directories for:” and look for lib
  8. Create new line click on the browse button and direct yourself to the allegro-4.2.2 \lib folder

Linking up Allegro-4.2.2 in Visual C++ 2008 & First Project

  1. Create New Visual C++ 08 Empty Project
  2. In solution Explorer right click on source folder Add New Item
  3. Add new .CPP file name it main
  4. Go to Project Properties > Configuration Properties > Linker > Input
  5. In Additional Dependecies add “alleg.lib”
  6. Copy and paste given source

 


#include <allegro.h>

int main(void)
{
	allegro_init();
	set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
	install_keyboard();

	//input for players positions
	while(!key[KEY_ESC])
		textout_ex(screen, font, "Allegro-4.2.2 working in Visual C++ 2008", 1, 12, 11, -1);

	//end program
	allegro_exit();
	return 0;
}
END_OF_MAIN()

 

Now Build and Run and you should have a window much like the image below.

Hope this helped!

Just a small mention to Allegro

Allegro is a game library supporting C/C++ distributed freely and their main site is Allegro Site where the library, documentation, source files, and much much more can be viewed, downloaded freely! Thank you for making and keeping Allegro a free game programming library!

Tags: , , , ,

9 Responses to “Setting up Allegro-4.2.2 in Visual C++ 08”

  1. Alvin Says:

    ok so i followed your steps but i coudnt find linker
    under project>properties>….. pleaqse help

  2. csfinch Says:

    My bad. While you are in your project solution. (i.e. you have a project opened)

    Go to Project > Project Properties.

    From their you’ll see a tree list on the left side. Click on

    Configuration Properties.
    Linker > Input

    Sorry I was sorta rushing through this.

    I’ve added you on my IM account under coden4fun, so if I see you online I will mention that I have indeed updated this with a comment, and have answered your question to the best of my knowledge.

    Good Luck!

  3. cecil Says:

    so i finally got allegro up and running in msvc 2008 express.

    so far so good. i used to use dev-cpp but most programming is on msvc so im trying to get rid of an extra ide i dont need.

    now. you have to set up the linker input for EVERY new allegro project. any tips on a project wizard?

  4. csfinch Says:

    You can make a template for your game in Visual C++ and for now even though I’m sure it’s not the preferred way in the game development community that is how I setup all of my games.

    So, let’s say I have a game template that has basic input, sound, visual effects, etc… and each of these classes I’ve just created can easily be used for Pacman, Tetris, Pong, Break-Out, etc… I create a Visual Studio C++ Template of all of those classes, and set that project up with the Allegro library, and BAM! I have a Visual C++ Template in Visual Studio that I can easily use for other games, which will save me much time on programming.

    Read this article from the MSDN

    website (http://msdn.microsoft.com/en-us/magazine/cc188697.aspx)

    Hopefully that will explain in details precisely how to do exactly what you would like to do.

    Thanks for reading the blog! ;)

  5. cecil Says:

    it seems that article is for exporting web, c#, and VB, item and project templates. msvc++ has no “export template” feature. not sure exactly how to go about doing it :(

  6. ogotai Says:

    Sorry bud, everything works just fine excepting your code. The first line looks a bit strange with no include file. Even after adding a proper file declaration your code doesnt work. I have managed to run allegro and build the code that works properly (found it somewhere else), but it seems like there is an error in yours.

  7. csfinch Says:

    Thanks for pointing that out. I have copied and pasted the latest code from my running test project for Allegro in Visual Studio 2008. The code that is now up works if you follow the directions carefully.

    Sorry for the inconvenience.

  8. meredithcn Says:

    I compile the code given and get a link error that it cannot open alleg.lib, any thoughts on why?

  9. csfinch Says:

    OK, the link is no longer there, and I have found people here are having a difficult time understanding the lib process. I’m going to rewrite this blog for you’ll, and post it on dreamincode.net!

    Meridthcn, you compiling the code and getting a linker error is most possibly not adding the lib files needed in the project from allegro correctly, or simply applying that you need those to your project.

    Whichever it is, I’ll give each of you’ll an email when the tutorial is on the other website, and I will most definitely make sure everything compiles correctly once you follow the instructions verbatim.

Leave a Reply