Sign in to follow this  
SreekanthNarayanan

Trouble with allegro

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?
[code]#include <allegro5/allegro.h>[/code]

Share this post


Link to post
Share on other sites
thanks for that. it's all workin now. :)
[quote name='Sik_the_hedgehog' timestamp='1307530433' post='4820883']
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?
[code]#include <allegro5/allegro.h>[/code]
[/quote]

Share this post


Link to post
Share on other sites
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??

[quote name='Sik_the_hedgehog' timestamp='1307530433' post='4820883']
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?
[code]#include <allegro5/allegro.h>[/code]
[/quote]

Share this post


Link to post
Share on other sites
[quote]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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this