Setting up Allegro-4.2.2 in Visual C++ 08

     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!

Advertisement

Tags: , , , ,

29 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! ;)

    • Gautham Says:

      Hey csfinch :)
      This guide has been very helpful. But as Cecil pointed out, VC++ users have to set up the project every time. Do you know of any project to template converters? Or if you have a template that would work in VC++, could you please share?

  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.

  10. Guernica Says:

    Thanks for the guide this worked great! been having troubles doing this for a while and this worked quick!

  11. Neaira Says:

    hello I’m trying to do a static link for allegro in vc2008 … how can I do that ?

  12. Uplifter Says:

    I followed your setup guide exactly, but when I copy pasted your program it is telling me that it skips #include and that all of the commands are not found.

  13. Botched Says:

    Thank you. I followed your steps from the “Linking up Allegro-4.2.2 in Visual C++ 2008 & First Project” section and it worked perfectly.

    In case you are curious, I did not follow the first section since I just copied the files into the compiler’s bin, lib, and include directories.

    Thanks again.

  14. Pokenerd Says:

    Ok – I’ve followed your instructions, and I didn’t get any compiler errors. However when I test the .exe from the debug folder – I get the following error: “This application has failed to start because alleg42.dll was not found. Re-installing the application may fix this problem.”

  15. Mono Says:

    Also when you start this you will have to copy paste the .dll files into your project debug folder for it to compile right

  16. Khaibit Says:

    sweet deal man, saved my ass a lot of time, haha. thanks! :D

  17. ralphus Says:

    Hey great mini tutorial. Tried for ages to get allegro to work with vs8 chanced across your blog and did it in minutes. Much appreciated. ta

  18. Luis Says:

    The code fails to Build. I get this error:

    Error 1 fatal error C1083: Cannot open include file: ‘pc.h’: No such file or directory c:\allegro\include\allegro\platform\aldjgpp.h 20

    What can I do?

  19. wap гей знакомства Says:

    я считаю: превосходно!

  20. sean Says:

    I ended up having to put some of the allegro dll’s in the project folder to get this to work

  21. Nesh Says:

    THANK YOU MAAAAAN!!!
    Finally!

    I had a problem, but I solved it copying the files from the folder ‘bin’ to the ‘Debug’ folder [The final one, where the user can find the compiled exe].

    (the files are 3 dlls)

  22. randompersonwithaquestion Says:

    hey i was wondering how do i put a picture in my projects i tried putting it near the .exe maybe im doing it wrong but can you put up a tutorial for it?

  23. Boddu Avinash Says:

    http://www.talula.demon.co.uk/allegro/wip.html
    Download the above link this is for allegro game programming library

    this above link doesnt have libraries and dll files.
    dont worry

    here is the link u will find

    http://www.megaupload.com/?d=1JQ8OTWU
    Download above link this link contains all libraries for allegro and also dll files in it.

    copy and paste it

    the following steps to install allegro
    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
    Under Options > Projects and Solutions > VC++ Directories
    4.Direct yourself to “Show Directories for:” in the combo box look for inlcude
    5.Create new line click on the browse button and direct yourself to the allegro-4.2.2 \include directory
    6.direct yourself to “Show Directories for:” and look for lib
    7.Create new line click on the browse button and direct yourself to the allegro-4.2.2 \lib folder

    8.Create New Visual C++ 08 Empty Project
    9.In solution Explorer right click on source folder Add New Item
    10.Add new .CPP file name it “main.cpp”
    11.In property manager tab where u can find at the bottom after solution explorer tab –Go to Project Properties > Configuration Properties > Linker > Input
    12.In Additional Dependecies add “alleg.lib”
    Copy and paste given source

    #include

    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()

  24. Muhammad Umar Says:

    >LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib’ i have got dis error….i follow all your instruction…help please!!

  25. Quik Says:

    hi, I’ve got it linked and the test code i’ve got works…however, when i put in other code in the main, then all it asks for is to “Press any key to continue” and then exits the program…none of my code gets run, not even the Allegro code. If i only put my functions in and leave the Allegro code, it runs. As soon as i try to use something like “cout” it doesnt work…

    What do i do?

    Thanks…

  26. Nancy Says:

    Hey, thanks for the guide. The code compiled fine but when I ran it I got this: “The program can’t start because alleg42.dll is missing from your computer. Try reinstalling the program to fix this problem.” I then copied the contents of bin to the Debug folder (Projects\projectName\Debug) and it worked (though for some reason I couldn’t close the window :/ Had to wait till it didn’t respond to close it) …Just thought I’d leave that here in case someone else gets the same error.

  27. arefblog Says:

    OK, thanks for the tutorial :)

  28. csfinch Says:

    Well, it’s been 2 years since I’ve written this, and it seems people are still commenting on this post, so I’ll leave it up. I’m going to do a revision and post it soon, so those who have a link error (in the future, for I’m sure those who had one has figured it out or have moved on) will have no trouble if they read and follow instructions verbatim.

    Thank you all for reading my post and thanking me for writing it. It truly has surprised me.

    I also want to personally thank Boddu Avinash for correcting my download and supplying the readers with all files needed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.