#1 Members - Reputation: 115
Posted 23 October 2012 - 01:29 AM
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?
I use Code::Blocks with GNU GCC Compiler, and Allegro 5 Libraries.
I'm a W.I.P., please be patient with me!
#2 GDNet+ - Reputation: 1547
Posted 23 October 2012 - 03:57 AM
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....
OpenChess - 1.0 done!
Classic RPG #1 - Task 9 -> January 1st 2013
#3 Crossbones+ - Reputation: 924
Posted 23 October 2012 - 01:48 PM
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.
#4 GDNet+ - Reputation: 1547
Posted 23 October 2012 - 03:06 PM
Sorry about that!
OpenChess - 1.0 done!
Classic RPG #1 - Task 9 -> January 1st 2013
#7 GDNet+ - Reputation: 1547
Posted 23 October 2012 - 04:01 PM
http://wiki.allegro.cc/index.php?title=Allegro_5
OpenChess - 1.0 done!
Classic RPG #1 - Task 9 -> January 1st 2013
#8 Members - Reputation: 115
Posted 24 October 2012 - 01:13 PM
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 use Code::Blocks with GNU GCC Compiler, and Allegro 5 Libraries.
I'm a W.I.P., please be patient with me!
#11 Members - Reputation: 592
Posted 24 October 2012 - 03:49 PM
it exists. Maybe you're not linking right. Hmm
EDIT:
I'm sorry
#include <allegro5/allegro_image.h>
all better?
Edited by Shaquil, 24 October 2012 - 03:54 PM.
#15 Members - Reputation: 115
Posted 24 October 2012 - 05:03 PM
I use Code::Blocks with GNU GCC Compiler, and Allegro 5 Libraries.
I'm a W.I.P., please be patient with me!
#16 Members - Reputation: 592
Posted 24 October 2012 - 06:01 PM
Change line 41 to:
if(display == NULL) {
The manual says that al_create_display returns NULL, so don't assume it's Boolean value.
That's a waste of time. if(!display) and if(display == NULL) are the same exact thing.
Also, remove my suggestion of the image addon stuff. I was wrong. I've run your code in Visual Studio 2012 Professional. It worked. I've attached a screenshot in dual-screen mode. I have no idea how to make allegro work with codeblocks, so I can't help you with figuring out what possible linkage problems might be occuring.
#17 Members - Reputation: 115
Posted 24 October 2012 - 06:41 PM
Well, here's my .cbp (Code Blocks Project file) that contains my .cpp file:
- { http://codepad.org/JCrRLUFQ } -
I use Code::Blocks with GNU GCC Compiler, and Allegro 5 Libraries.
I'm a W.I.P., please be patient with me!
#18 Members - Reputation: 592
Posted 24 October 2012 - 07:28 PM







