Trouble with allegro

Started by
7 comments, last by SreekanthNarayanan 12 years, 10 months ago
hey everyone,

i've just started with allegro and have configured code::blocks to run the same, including all the libraries n stuff.
here's the code that i tried to build:



#include<C:\allegro-5.0.3-mingw-4.5.2\include\allegro5\allegro.h>

int main(int argc, char* argv[])
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT,640,480,0,0);

BITMAP *pic = NULL;
pic = load_bitmap("picture.bmp",NULL);
blit(pic,screen,0,0,0,0,480,360);
readkey();

destroy_bitmap(pic);
return 0;
}
END_OF_MAIN();

and here's the build log:

Compiling: chk.cpp
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp: In function 'int main(int, char**)':
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:5:18: error: 'allegro_init' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:6:22: error: 'install_keyboard' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:7:23: error: 'set_color_depth' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:8:18: error: 'GFX_AUTODETECT' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:8:44: error: 'set_gfx_mode' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:11:41: error: 'load_bitmap' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:12:14: error: 'screen' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:12:36: error: 'blit' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:13:13: error: 'readkey' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:15:23: error: 'destroy_bitmap' was not declared in this scope
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp: At global scope:
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:18:14: error: expected constructor, destructor, or type conversion before ';' token
Process terminated with status 1 (0 minutes, 0 seconds)
11 errors, 0 warnings


any help would be appreciated.
Advertisement
Maybe if you instead of allegro_init() write al_init(). Maybe that will help.
You installed Allegro 5 but you're trying to write code for older versions. Allegro 5 is a completely different library, seriously. Go check the Allegro page to see what you should be using instead.

Also why not do this instead of that huge include path?
#include <allegro5/allegro.h>
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
thanks for that. it's all workin now. :)

You installed Allegro 5 but you're trying to write code for older versions. Allegro 5 is a completely different library, seriously. Go check the Allegro page to see what you should be using instead.

Also why not do this instead of that huge include path?
#include <allegro5/allegro.h>
i've run into another problem right now.. i've created two cpp files in the same project. they're independent with their own min functions obviously.. however, code::blocks says this when i build the project:



-------------- Build: Debug in first ---------------

Compiling: chk.cpp
C:\Users\Pentatonia\Documents\codeblocksproj\first\chk.cpp:4:5: warning: second argument of 'int main(int, char***)' should be 'char **'
Linking console executable: bin\Debug\first.exe
obj\Debug\chk.o: In function `main':
C:/Users/Pentatonia/Documents/codeblocksproj/first/chk.cpp:5: multiple definition of `main'
obj\Debug\event.o:C:/Users/Pentatonia/Documents/codeblocksproj/first/event.cpp:5: first defined here
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
2 errors, 1 warnings


-----------------------------------------------------------------------
why doesn't it realize that theyr'e two different programs and hence require different main functions??


You installed Allegro 5 but you're trying to write code for older versions. Allegro 5 is a completely different library, seriously. Go check the Allegro page to see what you should be using instead.

Also why not do this instead of that huge include path?
#include <allegro5/allegro.h>
why doesn't it realize that theyr'e two different programs and hence require different main functions??[/quote]

Have you included chk.cpp into the event.cpp file?

Im assuming that you've made some change to the code listed previously in this thread.
Programs are associated to projects. You cannot have more than one program per project.
Technically you can assign several programs to a single project (make different build targets and assign different files to them), but that probably isn't a good idea. You're better off making separate projects for separate programs.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
alright i guess i'll create a new project. i used to think of projects as a collection of programs. thanks!

This topic is closed to new replies.

Advertisement