Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Allegro 4.4.2 setup on MSVS9

This thread is locked; no one can reply to it. rss feed Print
Allegro 4.4.2 setup on MSVS9
myoung
Member #12,934
June 2011

I'm having problems getting Allegro 4.4.2 working on MSVS9. Does anyone know of a tutorial on how to get Allegro 4.4.2 working with MSVS9? I searched the Internet and can only find tutorials on getting Allegro 4.2 working with MSVS9. I think a specific and verbose walk-through would really be handy to help newbs like myself dabbling with Allegro 4.

Early last year I cobbled together a walk-through from other tutorials on how to get Allegro 4.2.3 working on MSVS9, from the installation of MSVS9 to compiling a simple Allegro program, including doing static linking. Since then I've been working here and there on a humorous Pac-Man clone. Though now I want to utilize PNG routines in this game without needing to include dlls for zlib and libpng in the release. I was told that Allegro 4.4.2 is the way to go, short of dumping Allegro 4 for Allegro 5, as the Allegro 4.4.2 libraries for download here can be statically linked. Forgive me for not having much of a command of compiler concepts. I know it's easy to say to someone asking for help to get with it and learn about their IDE before delving into game programming. Though I also see these annoying IDE issues as separate from pure game programming, granted, a good game programmer should be strong in both areas.

I'm going to transcribe my instructions on how to specifically get Allegro 4.2.3 working with MSVS9 to a text file and attach them to this thread. I was wondering if someone would help convert that walk-through from getting Allegro 4.2.3 working on MSVS9 to getting getting Allegro 4.4.2 working on MSVS9. Granted, if no one thinks such a tutorial is worthwhile, that's understandable. Thanks!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

http://www.allegro.cc/files/?v=4.4

Download the files for MSVC 9, and then configure your project to search the directories in them, allegro\bin for library searches, and allegro\include for header searches.

To static link, link against these libraries :

alleg44-monolith-static-mt.lib
loadpng.lib
zlib.lib

kernel32.lib
user32.lib
gdi32.lib
comdlg32.lib
ole32.lib
dinput.lib
ddraw.lib
dxguid.lib
winmm.lib
dsound.lib

(The first three will probably have different names, just use the static version, and use -mt or -md depending on how your project is configured to link to the C runtime).

AMCerasoli
Member #11,955
May 2010
avatar

I was told that Allegro 4.4.2 is the way to go, short of dumping Allegro 4 for Allegro 5, as the Allegro 4.4.2 libraries for download here can be statically linked.

Allegro 5 also comes with libraries that can be linked statically to your game. In the wiki you have a tutorial explaining how to do it, statically, dynamically including how to do it using the monolith version. You'll end up with just one an single file :).

myoung
Member #12,934
June 2011

Hi Edgar,

Currently I'm getting this error...

"This application has failed to start because allegro.dll was not found. Re-installing the application max fix this problem."

Here's everything I've done so far in trying to get it to work from the ground-up...

Install Visual C++ 2008 Express Edition.

Download the Allegro 4.4.2 library (allegro-4.4.2-msvc-9.0.zip).

Unzip allegro-4.4.2-msvc-9.0.zip to "C:\allegro-4.4.2-msvc-9.0".

Start Visual C++ 2008.

Go to: Tools --> Options.
Go to: Projects and Solutions --> VC++ Directories.
Under "Show directories for:" select "Include files".
Create a new line and select the Allegro pre-built library's include folder, "C:\allegro-msvc9-4.2.3\include".
Under "Show directories for:" select "Library files".
Create a new line and select the Allegro pre-built library's lib folder, "C:\allegro-msvc9-4.2.3\lib".
Click OK to close Options.

Create a new Visual C++ 2008 Empty Project...
File --> New --> Project..., General, Empty Project
Enter a name for the project and click OK. In this example we'll call the project "TestProject".
Go to: Project --> Properties.
Go to: Configuration Properties --> Linker --> Input.
Under "Additional Dependencies" enter "allegro-4.4.2-monolith-static-mt.lib" and click OK.
Go to: Project --> Add New Item..., select C++ file, call it main.cpp, and click "Add".
Add the following code to main.cpp...

#include <allegro.h>
#include <stdio.h>

int main(void) {

set_color_depth(16);
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0) != 0) {
allegro_message("Couldn't set graphics mode!\n");
return 1;
}

textprintf_centre_ex(screen, font, screen->w/2, 196, makecol(0, 0, 0), makecol(0, 0, 0), "Hello world!");

while (key[KEY_ESC] == 0) { // wait for ESC to be pressed
}

allegro_exit();
return 0;
}
END_OF_MAIN()

Click --> Debug --> Start Debugging (or press F5 or click on the green "play" button). You will be prompted to build the project. Click Yes.

Matthew Leverton
Supreme Loser
January 1999
avatar

Project Properties / Debugging:

Environment: PATH=C:\allegro-4.4.2-msvc-9.0\bin;%PATH%

myoung
Member #12,934
June 2011

Hmm, I tried adding the path but I still get the same error. I cannot find any file on my computer named "allegro.dll".

Under "Additional Dependencies" I changed "allegro-4.4.2-monolith-static-mt.lib" to "allegro-4.4.2-md.lib" and then I get the error "This application has failed to start because MSVCR90.dll was not found. Re-installing the application max fix this problem."

Matthew Leverton
Supreme Loser
January 1999
avatar

It shouldn't be asking for it since you are static linking. Double check which libraries you are linking against.

myoung
Member #12,934
June 2011

Thanks again for the help.

I know that with Allegro 4.2.3 I had to do the following to get static linking working...

Download dx70_min.zip and extract to "C:\dx70_min".
Go to: Tools --> Options
Go to: Projects and Solutions --> VC++ Directories
Under "Show directories for:" select "Include files".
Create a new line and select "C:\dx70_min\include".
Under "Show directories for:" select "Library files".
Create a new line and select "C:\dx70_min\lib".

Project Properties --> Configuration Properties
C/C++ --> Preprocessor --> Preprocessor Definitions: ALLEGRO_STATICLINK
C/C++ --> Code Generation --> Runtime Library: /MT
Linker --> Input --> Additional Dependencies:
alleg_s_crt.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib dinput.lib ddraw.lib dxguid.lib winmm.lib dsound.lib
Linker --> Command Line --> Additional Options: /LTCG

I just made those changes (except I specified "allegro-4.4.2-monolith-static-mt.lib" instead of "alleg_s_crt.lib") and now I get these errors:

main.obj : error LNK2001: unresolved external symbol _key
main.obj : error LNK2001: unresolved external symbol _font
main.obj : error LNK2001: unresolved external symbol _screen

torhu
Member #2,727
September 2002
avatar

Are those the only three errors you get?

myoung
Member #12,934
June 2011

Yep, just those 3 errors, well, those 3 and one more fatal error simply stating there are unresolved externals. When I comment out what the errors are referring to, Allegro symbols, we go back to that first error message...

"This application has failed to start because allegro.dll was not found. Re-installing the application max fix this problem."

I must not have configured something in MSVS9 properly. I got it figured out with 4.2.3 with the help of a hold your hand tutorial and pretty pictures as it's easy for a newb to get lost in the sea of menus in Visual Studio. :-/ If I can get this figured out I'm so going to create a hold your hand tutorial for this.

torhu
Member #2,727
September 2002
avatar

Hmmm... are you sure that you've done the exact settings that you've posted? And are you sure you haven't configured the Debug build, then tried the Release build, or something like that?

That it asks for allegro.dll is a clear sign that you're linking with the wrong library. The missing symbols point in the same direction.

myoung
Member #12,934
June 2011

Yeah, for a bit I think I was messing with debug and running release and vice-versa, but I then started configuring both settings the same and was mindful of those settings. If only I could formulate the instructions to make it work! I have to be missing some setting(s). I tried linking various pre-built 4.4.2 lib files and various combinations of settings with no luck, then went back to just dynamic linking with 4.2.3 and no problems. I installed MSVS9 on a different system with a clean install of Windows to have a 2nd machine to tinker with. I may mess with it more, but I'm starting to feel maybe I should ditch the obsession of static linking everything, stick with dynamic linking with 4.2.3, and after this current project, move onto Allegro 5 or something else. So I'll need to include some dlls with the release, big deal, right? Still, wish I could figure this damn thing out. Granted, I should have been working more on my game more instead of obsessing about static linking everything! Doh!

torhu
Member #2,727
September 2002
avatar

You could try just starting afresh by creating a new MSVC project, in case there are some settings you are not aware of. But I suppose you've already done that. Or you could just get on with your game ;D

myoung
Member #12,934
June 2011

Yeah, just tried again with another new project and same result. Maybe I'll try MSVS10 or MinGW with the corresponding pre-built libraries.

torhu
Member #2,727
September 2002
avatar

The binary package is broken, allegro-4.4.2-monolith-static-mt.lib references allegro.dll :-/

If you search inside allegro-4.4.2-monolith-static-mt.lib, you can see that it contains the string "allegro.dll" several times. Other files in the package seem to be broken in the same way.

Matthew Leverton
Supreme Loser
January 1999
avatar

You could ask Michał Cichoń to fix the packages. In the meantime, just use whatever works. When you want to release your game, you could probably use the 4.4 static MinGW binaries.

myoung
Member #12,934
June 2011

Sounds good! Thanks for the replies!

Go to: