# [HELP] Installing Allegro on Linux

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

## Recommended Posts

Hello, I'm using Code::Blocks 10.05 on Xubuntu 11.04 and having trouble getting allegro to work right with C++ and the g++ compiler.

/* * Example program for the Allegro library, by Shawn Hargreaves. * * This is a very simple program showing how to get into graphics * mode and draw text onto the screen. */ #include <allegro.h> int main(void) { /* you should always do this at the start of Allegro programs */ if (allegro_init() != 0) return 1; /* set up the keyboard handler */ install_keyboard(); /* set a graphics mode sized 320x200 */ if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); return 1; } } /* set the color palette */ set_palette(desktop_palette); /* clear the screen to white */ clear_to_color(screen, makecol(255, 255, 255)); /* you don't need to do this, but on some platforms (eg. Windows) things * will be drawn more quickly if you always acquire the screen before * trying to draw onto it. */ acquire_screen(); /* write some text to the screen with black letters and transparent background */ textout_centre_ex(screen, font, "Hello, world!", SCREEN_W/2, SCREEN_H/2, makecol(0,0,0), -1); /* you must always release bitmaps before calling any input functions */ release_screen(); /* wait for a keypress */ readkey(); return 0; } END_OF_MAIN() 

That's the code I'm trying to get working, very basic. It's returning:
In Function 'acquire_screen' undefined reference to 'screen'
In Function 'acquire_screen' undefined reference to 'screen'

undefined reference to '_install_allegro_version_check'
undefined reference to 'install_keyboard'
undefined reference to 'set_gfx_mode'
undefined reference to 'set_gfx_mode'
undefined reference to 'set_gfx_mode'
undefined reference to 'allegro_error'
undefined reference to 'allegro_message'
undefined reference to 'desktop_palette'
undefined reference to 'set_palette'
undefined reference to 'makecol'
undefined reference to 'gfx_driver'
undefined reference to 'gfx_driver'
undefined reference to 'gfx_driver'
undefined reference to 'gfx_driver'
undefined reference to 'font'
undefined reference to 'screen'
undefined reference to 'textout_centre_ex'

Sx2Kirby

##### Share on other sites
#including <allegro.h> is not enough, you must also link your program with the allegro library.

##### Share on other sites
In linker Settings I have 'allegro-config --libs'

##### Share on other sites
bump, I really need help with this

##### Share on other sites
What does "allegro-config --libs" output ?
Does the lib file exist there ?

##### Share on other sites

What does "allegro-config --libs" output ?
Does the lib file exist there ?

In outputs:

-L/user/lib -Wl, -Bsymbolic-functions -lalleg-4.2.2

##### Share on other sites
The next step is to check that you have a file /user/lib/liballeg-4.2.2.so, and that it defines the required symbols (you can use the nm command for that, or nm -d).
If you have the lib somewhere else, it's allegro-config that must be broken / out of sync, so you could either reinstall, or specify the path manually.

##### Share on other sites

The next step is to check that you have a file /user/lib/liballeg-4.2.2.so, and that it defines the required symbols (you can use the nm command for that, or nm -d).
If you have the lib somewhere else, it's allegro-config that must be broken / out of sync, so you could either reinstall, or specify the path manually.

yep I have liballeg-4.2 and allegro-config does work
And liballeg-4.2.2.so is in the correct place (/usr/lib)

##### Share on other sites
allegro-config tells the linker to search for the file in /user/lib, and your file is in /usr/lib.
cf 2nd part of my previous comment

##### Share on other sites

allegro-config tells the linker to search for the file in /user/lib, and your file is in /usr/lib.
cf 2nd part of my previous comment

Sorry for seeming like a noob, but how exactly do you manually set the path?
Thanks fro all of this by the way

##### Share on other sites
allegro-config --libs
(backquotes included), you have to put
-L/usr/lib -Wl, -Bsymbolic-functions -lalleg-4.2.2

Same error

##### Share on other sites
You can try with just:-L/usr/lib -lalleg-4.2.2You can check the lib file for symbols.

Reproducing (or not) manually outside of codeblocks would also give hints.