Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Installing Allegro 5 in Code::Blocks

This thread is locked; no one can reply to it. rss feed Print
Installing Allegro 5 in Code::Blocks
DarkFlame
Member #14,429
July 2012

I spent several hours yesterday trying to get this working. I've tried several methods and I simply can't get it working.

I'm using MinGW 4.6.1 trying to install Allegro 5.0.7.

The easiest method of course is to use devpaks, but that isn't working. The devpak plugin in Code::Blocks shows the latest version of Allegro to be 5.0.4 (But devpaks.org says 5.0.6...) and it won't let me download it anyway as it says the download is corrupt every time.
So the next method is to install using the binaries on this site, which I've tried (several times) I can move the files to the proper places pretty easily without a hitch mostly (Some names are very different from what I've seen in guides around the web) The problem comes in what happens next. I've seen things that say that it should just work automatically now, I've seen things that say you have to link everything in the lib folder, I've seen things that say you have to link one file. I don't know what to do here.

Following the guide on the wiki, I get to the part where it says to "add the entry ALLEGRO_STATICLINK to it." because "it" is not defined. I don't know where to add this entry or how. The next block of code makes it doubly more confusing because it's obviously pseudocode, but it's the only code I see anywhere.

So what am I missing?

Cassio Renan
Member #14,189
April 2012
avatar

I don't know what guide you're following, but if it is this one:

http://wiki.allegro.cc/index.php?title=Windows_Vista,_Code::Blocks_10.05_and_Allegro_5

"it" is Project->Build Options->Compiler Settings->#defines. Just type ALLEGRO_STATICLINK there.
Or you could also just type:

#define ALLEGRO_STATICLINK

in the very beginning of your code and it should work fine.

If you managed to follow the tutorial to this point, it should be working now. If it isn't, please post any errors you got when trying to compile a project. There's a nice example for testing in here: http://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays
Just copy the first block of code.

DarkFlame
Member #14,429
July 2012

Yeah, I'd tried that but I'm getting another error (In fact I got one other error before this which I fixed)

After Code::Blocks compiles it, it starts executing it fine but then there's an error box. https://dl.dropbox.com/u/4680081/entrypointnotfounderror.PNG
The error I was getting before was similar, it was about a file being missing (lib_s_sjlj something I think) I did a search with Everything and found a file by that name in my GIMP installation so I copied it over to my MinGW bin folder. The error stopped happening and I started getting the one pictured above instead.

EDIT: Here's the original error which I fixed: https://dl.dropbox.com/u/4680081/systemerror.PNG

Cassio Renan
Member #14,189
April 2012
avatar

Did you added C:/MinGW/bin(or whenever your bin folder is in your installation) to your PATH environment variable? Check also if MINGDIR is there.

Finally, check if Code::Blocks is using the correct MinGW installation. Go to Settings->Compiler and debugger settings->Toolchain Executables and see if the compiler's installation directory is the correct path to your MinGW installation(Sometimes the path is to the built-in MinGW from C::B, although this shouldn't pose these exact same problems. Just change it to your custom installation)

EDIT: After you are done, press Ctrl+F11 to rebuild your project from scratch.

DarkFlame
Member #14,429
July 2012

Yep, that's in my path and MINGDIR is there (Set to the same dir)

Code::Blocks SAYS it's using the right one.

(I didn't change anything as I've done both of those before)

One thing I found is that I'm using MinGW 4.6.1. The only Allegro binaries for 4.6.1 have a (TDM) next to them. After some research, it seems that means that it was compiled for some special version of MinGW that I don't have. So I tried to upgrade to MinGW 4.6.2 and the correct Allegro binaries, but nothing changed. I'm going to try completely uninstalling Code::Blocks, MinGW, and Allegro then start again from the beginning. If that doesn't work, then I think I'll give up and switch to SFML.

Cassio Renan
Member #14,189
April 2012
avatar

When you say that path and MINGDIR are on the same folder, do you mean the exact same folder?

path should be C:/MinGW/bin
MINGDIR should be C:/MinGW

I know I'm insisting in something apparently too small, but your problem is definitely in your MinGW installation. You don't need to uninstall Allegro or C::B, but you may try re-checking the compiler.
Those two shared libraries you are getting errors from are MinGW's. If they are giving errors, either your MinGW installation has a problem, or you're missing something when you're linking you project.

Since I saw you changed your installation already, you might as well check if you haven't missed any of these libraries in your linker(but only if you're linking statically):

1 - libgdiplus.a
2 - libuuid.a
3 - libkernel32.a
4 - libwinmm.a
5 - libpsapi.a
6 - libopengl32.a
7 - libglu32.a
8 - libuser32.a
9 - libcomdlg32.a
10 - libgdi32.a
11 - libshell32.a
12 - libole32.a
13 - libadvapi32.a
14 - libws2_32.a
15 - libshlwapi.a

If none of this helps, I'm over my capacity here(I'm really just a beginner witch spent a lot of time installing this on a few PCs). I'll continue helping whenever I can, though.

DarkFlame
Member #14,429
July 2012

Yeah, that's what I meant about the PATH, sorry.

Most likely the problem is in the linking, since I've never done this before and I don't really know how (Not to mention every guide I find contradicts each other about what I have to link and where)
The reason I was saying I would uninstall everything and start over is because I've been messing with it so much that I think I might have messed something up. I just want to start over from a clean slate.

I did not have any of those linked. Nothing I found said to link them.
I was actually thinking I would do it dynamically, but only because it seemed easier. I should probably learn static since that's generally considered better practice I think.

I'm going to start from scratch like I said this evening, then I'll get back on if it worked.

EDIT: Sorry, I got much busier than I expected and still haven't had time to devote to this.

Haledemus
Member #14,446
July 2012

Hello,

I have recently decided to try loading code blocks with allegro 5.0.0 and followed the directions from http://www.allegro.cc/forums/thread/606041. Everything seemed to be working just fine but when I attempted step 17 I noticed that the file "liballegro.dll.a" was actually in another path. I don't know if that is what has been causing the errors during the build stage. The path that I found this file in is C:\CodeBlocks\MinGW\allegro\build\lib. anyhow, it does not seem to build correctly as I have received a whole slew of errors:

C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|2|error: allegro5/allegro.h: No such file or directory|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp||In function 'int main(int, char**)':|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|7|error: 'ALLEGRO_DISPLAY' was not declared in this scope|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|7|error: 'display' was not declared in this scope|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|9|error: 'al_init' was not declared in this scope|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|14|error: 'al_create_display' was not declared in this scope|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|20|error: 'al_map_rgb' was not declared in this scope|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|20|error: 'al_clear_to_color' was not declared in this scope|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|22|error: 'al_flip_display' was not declared in this scope|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|24|error: 'al_rest' was not declared in this scope|
C:\Documents and Settings\Harold.SAMURAI\Desktop\Haledemus\main.cpp|26|error: 'al_destroy_display' was not declared in this scope|
||=== Build finished: 10 errors, 0 warnings ===|

Please help me as this is my second attempt at this and it has been an utter failure :(

Arthur Kalliokoski
Second in Command
February 2005
avatar

Haledemus said:

error: allegro5/allegro.h: No such file or directory

That caused all the other errors. It won't try to link to a library until all the source file compile correctly. I don't know how to fix it in Code Blocks, sorry.

They all watch too much MSNBC... they get ideas.

Haledemus
Member #14,446
July 2012

Thanks anyway. I will try again when I get a chance and if I ever get it to work I will post something up to help the next guy who goes down the same path as me. :)

Neil Roy
Member #2,229
April 2002
avatar

Personally, I use Code::Blocks nightly build with MinGW-TDM 4.6.1 (they fix some problems with MinGW you'll run into). Then you can download Allegro 5.0.7 binaries compiled with 4.6.1 TDM.

When I add in libraries to new A5 projects, I add in the following libraries in this order:

liballegro-5.0.7-static-mt.a
liballegro_acodec-5.0.7-static-mt.a
liballegro_audio-5.0.7-static-mt.a
libopenal-1.14-static-mt.a
libvorbisfile-1.3.2-static-mt.a
libvorbis-1.3.2-static-mt.a
liballegro_color-5.0.7-static-mt.a
liballegro_dialog-5.0.7-static-mt.a
liballegro_font-5.0.7-static-mt.a
liballegro_image-5.0.7-static-mt.a
liballegro_memfile-5.0.7-static-mt.a
liballegro_physfs-5.0.7-static-mt.a
liballegro_primitives-5.0.7-static-mt.a
liballegro_ttf-5.0.7-static-mt.a
libdumb-0.9.3-static-mt.a
libFLAC-1.2.1-static-mt.a
libfreetype-2.4.8-static-mt.a
libogg-1.2.1-static-mt.a
libzlib-1.2.5-static-mt.a
gdiplus
uuid
kernel32
winmm
psapi
opengl32
glu32
user32
comdlg32
gdi32
shell32
ole32
advapi32
ws2_32
shlwapi

And I compile them with #define ALLEGRO_STATICLINK at the top of my source code so no DLLs needed with your projects.

I also have Code::Blocks compress my executable with UPX (with --best command line switch) which does a fantastic job. My currect project got compressed down from 888K to 335K.

---
“I love you too.” - last words of Wanda Roy

Haledemus
Member #14,446
July 2012

Hi guys,

sorry, I did not know where to post this question but I finally was able to laod codeblocks and allegro into my system and it works. Then I looked at the allegro site and found this:

Allegro 5 is the latest major revision of the library, designed to take advantage of modern hardware (e.g. hardware acceleration using 3D cards) and operating systems. Although it is not backwards compatible with earlier versions, it still occupies the same niche and retains a familiar style.

My book is for allegro 4.2! does this mean I cannot use allegro 5.0? Just checking because I have rammed my head up against a brick wall year after year after year trying to match up compilers and books to no avail. Now that I thought I have everything set I find that I may be mistaken. Please tell me I can us 5.0 because I am about to lose my mind!!!

J-Gamer
Member #12,491
January 2011
avatar

A5 has a completely different API than A4. You can still try to get the concepts of game programming from the book though.

" There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo
"If your body was a business, thought would be like micro-management and emotions would be like macro-management. If you primarily live your life with emotions, then you are prone to error on the details. If you over-think things all the time you tend to lose scope of priorities." - Mark Oates

Neil Roy
Member #2,229
April 2002
avatar

You can still use CodeBlocks (with MinGW GNU compiler) and Allegro 4. Once you learn enough about programming and are more familiar with Allegro you can then make the move to Allegro 5. 4 is a very good spot to start from, it's easy to use.

I'm using both myself. I'm currently updating an older game of mine created with the classic Allegro and currently using the latest version of Allegro 4. And I am creating newer versions of other games with Allegro 5.

If you have a book on game programming, by all means keep using Allegro 4, game programming concepts are independent of libraries so you'll still probably pick up some valuable information from the book. They obviously have good taste in libraries. :D

---
“I love you too.” - last words of Wanda Roy

Haledemus
Member #14,446
July 2012

Hey guys,

Thanks for the advice. I really need some positive reinforcement right about now as this has been an on going ordeal for me. Not to mention the fact that it took me nearly three weeks to get codeblocks and allegro 5 to even work on my computer in the first place. Now, I have to do it all over again and to my understanding allegro 5 and allegro 4.2 are two different beasts even when it comes to the installation. Well, I suppose it is all worth it in the end as long as it works. Thanks again :).

Go to: