Linking Allegro troubles

Started by
4 comments, last by Aldacron 11 years, 9 months ago
Hello, can somebody please help me or link me to a tutorial for my problem. i have looked online foe about an hour and couldn't finda anything. I am trying to link allegro on ubuntu 12.04 (its 32-bit not sure if that matters (probably doesn't)) on the Code::Blocks IDE. when i put a sample project from the internet in :


#include </usr/include/allegro.h> //the /usr/include/allegro.h is where allegro is on my hardrive.

int main()
{
//Initialize Allegro
allegro_init();

//Set the resolution to 640 x 480 with SAFE autodetection.
set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);

//Install the keyboard handler
install_keyboard();

//Print your welcome message to the screen
textout(screen, font, "Hello Dream.In.Code! This is my first Allegro Program", 1, 1, 10);
textout(screen, font, "Press ESCape to quit.", 1, 12, 11);

//Loop until escape is pressed
while(! key[KEY_ESC])
poll_keyboard();

//Exit program
allegro_exit();
return 0;
}

END_OF_MAIN();


i get these errors:


/usr/include/allegro/alcompat.h|157|error: undefined reference to '_textmode'|
/usr/include/allegro/alcompat.h|157|error: undefined reference to 'textout_ex'|
/home/matt/C++Crap/Allegro /main.cpp|6|error: undefined reference to '_install_allegro_version_check'|
/home/matt/C++Crap/Allegro /main.cpp|9|error: undefined reference to 'set_gfx_mode'|
/home/matt/C++Crap/Allegro /main.cpp|12|error: undefined reference to 'install_keyboard'|
/home/matt/C++Crap/Allegro /main.cpp|15|error: undefined reference to 'font'|
/home/matt/C++Crap/Allegro /main.cpp|15|error: undefined reference to 'screen'|
/home/matt/C++Crap/Allegro /main.cpp|16|error: undefined reference to 'font'|
/home/matt/C++Crap/Allegro /main.cpp|16|error: undefined reference to 'screen'|
/home/matt/C++Crap/Allegro /main.cpp|20|error: undefined reference to 'poll_keyboard'|
/home/matt/C++Crap/Allegro /main.cpp|19|error: undefined reference to 'key'|
/home/matt/C++Crap/Allegro /main.cpp|23|error: undefined reference to 'allegro_exit'|
||=== Build finished: 12 errors, 0 warnings ===|


please help me!!!
Advertisement
Anybody
When you have linker problems like this, you need to post the command line you are using. Source snippets don't help in this case. Otherwise, we can only just guess.
The problem is that i dont know what to link. i put the code in because i thought it might help show what i need to link.
I remember having problems with Code::blocks as well with allegro, but that just may be my memory.
When I worked with allegro, I used Dev-C++. There's another post here in the forum, I'll just quote what another member said:

[size=1]in Dev-C++ go to the Tools menu and click Check for updates/Packages. Select a devpak server from the drop down menu and click Check for updates. You'll see a list of packages that you can download, find Allegro and check it and download it.[/quote]

So that's quite easy.

Then again..


You shouldn't use Dev-C++. It's very old, extremely buggy, and will hinder the process of learning to program.[/quote]
All of those missing symbols are from allegro, so you need to link with whichever version of the library you have. Assuming you are using GCC to compile, then the library should be named something like liballegro.a or some such.

This topic is closed to new replies.

Advertisement