http://codepad.org/aG4zacD3
My issue is that every time I compile & run it, It waits a couple seconds then crashes. Like, stops responding.
Does anyone have a clue what I'm doing wrong?
[Allegro 5] Game Crash
Your error code states "Line 29: error: allegro5/allegro.h: No such file or directory", are you sure that you're using the right path for allegro.h ?
I noticed errors in your code:
All you're doing is checking if al_init() returns false... Yet you never called al_init().
You need to call the following right before the check to see if they return false.
al_init();
al_install_keyboard();
ect....
I noticed errors in your code:
if(!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
All you're doing is checking if al_init() returns false... Yet you never called al_init().
You need to call the following right before the check to see if they return false.
al_init();
al_install_keyboard();
ect....
I have to disagree with the error you pointed out. I use conditional checks like that in my code and I have never had an issue. With his code it becomes somewhat condensed by calling the method and checking it's false. If it is false it exits the program, if it's true it continues on.
al_init() is called in this usage, it just saves an additional line by calling it in one if statement, than calling it, and then checking 3-7 lines later.
In response to the original question, it sounds most likely what Black-Rook suggested, that you may not have linked the libraries correctly to your project. Which IDE are you using?
Regards,
Stitchs.
al_init() is called in this usage, it just saves an additional line by calling it in one if statement, than calling it, and then checking 3-7 lines later.
In response to the original question, it sounds most likely what Black-Rook suggested, that you may not have linked the libraries correctly to your project. Which IDE are you using?
Regards,
Stitchs.
Oops, was 3am while writing! Guess I wasn't fully thinking there. Yes he is right, it goes through the function on the check while performing the inialization, then returns true or false.
Sorry about that!
Sorry about that!
Have you made a project in CodeBlocks using Allegro 5 before? I just wonder if you have your linkers have been properly set.
Allegro wiki has all the answers for correctly setting it up.
http://wiki.allegro.cc/index.php?title=Allegro_5
http://wiki.allegro.cc/index.php?title=Allegro_5
First things first, yes, in fact this .cpp file is IN a Code::Blocks project file, linked to all allegro things necessary. I have followed that Allegro 5 tutorial, and it's not the projects fault (I think).
So I set some breakpoints (well, I printed at various points in code)
And tracked it down to which line it crashes on, and:
http://codepad.org/kOFCWkA5
It seems to crash at line 59. "al_set_target_bitmap(al_get_backbuffer(display));"
I really need someone who's advanced to help me out, because the answer is not exactly obvious as to why it crashed.
So I set some breakpoints (well, I printed at various points in code)
And tracked it down to which line it crashes on, and:
http://codepad.org/kOFCWkA5
It seems to crash at line 59. "al_set_target_bitmap(al_get_backbuffer(display));"
I really need someone who's advanced to help me out, because the answer is not exactly obvious as to why it crashed.
I'm in class, so I can't exactly check, but off the top of my head:
Add these two lines:
and somewhere before you create the bitmap
Add these two lines:
#include <allegro5/image.h>
and somewhere before you create the bitmap
al_init_image_addon();
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement