# Trouble with allegro

This topic is 2453 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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;
blit(pic,screen,0,0,0,0,480,360);

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 on other sites
Maybe if you instead of allegro_init() write al_init(). Maybe that will help.

##### 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?
#include <allegro5/allegro.h>

##### Share on other sites
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>

##### 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 **'
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>

##### Share on other sites
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 on other sites
Programs are associated to projects. You cannot have more than one program per project.

##### Share on other sites
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.

##### Share on other sites
alright i guess i'll create a new project. i used to think of projects as a collection of programs. thanks!