Sign in to follow this  
Sx2Kirby

[HELP] Installing Allegro on Linux

Recommended Posts

Sx2Kirby    107
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.

[code]/*
* 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()
[/code]

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'
undefined reference to 'readkey'

Thanks in advance,
Sx2Kirby

Share this post


Link to post
Share on other sites
Sx2Kirby    107
[quote name='SriLumpa' timestamp='1313271406' post='4848750']
What does "allegro-config --libs" output ?
Does the lib file exist there ?
[/quote]

In outputs:

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

Share this post


Link to post
Share on other sites
SriLumpa    198
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 this post


Link to post
Share on other sites
Sx2Kirby    107
[quote name='SriLumpa' timestamp='1313657471' post='4850667']
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.
[/quote]

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 this post


Link to post
Share on other sites
Sx2Kirby    107
[quote name='SriLumpa' timestamp='1313998033' post='4852158']
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
[/quote]

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

Share this post


Link to post
Share on other sites
SriLumpa    198
Instead of
[code]`allegro-config --libs`[/code]
(backquotes included), you have to put
[code]-L/usr/lib -Wl, -Bsymbolic-functions -lalleg-4.2.2[/code]

Share this post


Link to post
Share on other sites
SriLumpa    198
You can try with just:[code]-L/usr/lib -lalleg-4.2.2[/code]You can check the lib file for symbols.

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

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