NOGDUS $1670.00 has been donated to NOGDUS!
June 29, 2017, 05:53:19 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Installing Allegro in Visual C++ 2008 Express  (Read 8716 times)
0 Members and 1 Guest are viewing this topic.
Richard Marks
Administrator
Offline Offline

Respect: 3425
« on: April 07, 2010, 02:54:02 PM »

Installing Allegro in Visual C++ 2008 Express

This short tutorial will step you through installing Allegro version 4.2.2 for use with Microsoft Visual C++ 2008 Express Edition. (MSVC9)

First, click here and download Allegro Version 4.2.2 pre-compiled binary for Microsoft Visual C++ 2008 Express.

This is Allegro version 4.2.2 pre-compiled and ready for use with Visual C++ 2008 Express.
I use this version and not the latest version because I found this version to be more stable IMHO.
If you want the latest version, then this tutorial isn't for you.

Step 1 - Installation of the Library Files

Extract the files from the Allegro422.zip file to a place on your hard drive.
I recommend that you place all your third-party libraries in a directory called Libraries, and preferably off your home folder or hard drive root.

So if you are on Vista, this is C:\Users\username\Libraries\
On XP, this is C:\Libraries\

Extract the files, and you should have:

LibraryPath\Allegro422\bin\
LibraryPath\Allegro422\include\
LibraryPath\Allegro422\lib\

Where LibraryPath is the path to the Libraries directory I just told you to create.

Step 2 - Telling Visual C++ Where to Find the Library Files

Open Visual C++ 2008 Express, and click the Tools menu, then choose Options.
Click VC++ Directories on the left side under Projects and Solutions.
On the right side, under the Show directories for: label, change the drop-down box to Include files.
Click the New Line button (folder with a starshine) and then click the ellipses button (...) and browse to the include directory for Allegro that we just installed.
Repeat the procedure for the library files in the drop-down and choose the lib folder.

Step 3 - Adding the Allegro DLL to the PATH

This process varies for the OS. So if you don't know how to edit the PATH for your computer, google "How to change PATH environment setting in {Your Operating System Here}" and add the bin directory from the Allegro installation to your PATH environment variable.

Step 4 - Test the Installation

Choose File -> New Project
Choose Win32 Project
Enter "AllegroTest" for the Name
Click OK
Click Application Settings
Check the Empty Project check-box
Click Finish

Add a main.cpp file to your project, and in the file, add this code:
Code:
#include <allegro.h>
#pragma comment(lib, "alleg.lib")

int main(int argc, char* argv[])
{
allegro_init();
install_timer();
install_keyboard();
set_color_depth(24);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
BITMAP* backBuffer = create_bitmap(SCREEN_W, SCREEN_H);
const int WHITE = makecol(255, 255, 255);
while(!key[KEY_ESC])
{
clear_bitmap(backBuffer);
textprintf_ex(backBuffer, font, 8, 32, WHITE, -1, "Hello World!");
blit(backBuffer, screen, 0, 0, 0, 0, backBuffer->w, backBuffer->h);
rest(1);
}
destroy_bitmap(backBuffer);
return 0;
}
END_OF_MAIN()

Compile the project and run it.
If nothing fails, you're done. If you've got any errors, post them here and I'll help you sort it out.

Thanks for reading.
Logged

Tags: Allegro msvc9 visual studio 2008 express c++ visual c++ installing allegro 
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
.: Theme by Richard Marks :.
Valid XHTML 1.0! Valid CSS!