2

what I'm including wrong ? I am using codeblocks + allegro5 + ubuntu 11.10

and getting this 2 errors

undefined reference to 'al_init_image_addon' undefined reference to `al_init_primitives_addon'|

I did install allegro5 correctly with all the dependencies. The first tutorial on loading the allegro.h works fine, it creates a normal window apart from the xterm window. I am following the "show in fullscreen tutorial" from the allegro wiki

#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include <allegro5/allegro_primitives.h>
#include "allegro5/allegro_native_dialog.h"

int main()
{

    ALLEGRO_DISPLAY *display = NULL;
    ALLEGRO_DISPLAY_MODE disp_data;

    al_init();
    al_init_image_addon(); // <---------ERROR HERE
    al_init_primitives_addon();// < --------ERROR HERE TOO

    al_set_new_display_flags(ALLEGRO_FULLSCREEN);
    display = al_create_display(disp_data.width,disp_data.height);

    al_rest(3);
    al_destroy_display(display);

    return 0;
}
HoNgOuRu
  • 717
  • 4
  • 13
  • 26

2 Answers2

1

In the event anyone has this issue, the fix is adding allegro_image-5.0 to your pkg-config path e.g.:

gcc game.c -o game $(pkg-config --cflags --libs allegro-5.0 allegro_image-5.0)
ben lemasurier
  • 2,582
  • 4
  • 22
  • 37
0

well, after doing a little google search and posting at allegro's homepage I got the correct answer,

I was missing the .so files in the linker section under TOOLS > Compiler&DEbugger > LINKER.

I had to add these lines

/usr/lib/liballegro_dialog.so
/usr/lib/liballegro_color.so
/usr/lib/liballegro_audio.so
/usr/lib/liballegro_image.so
/usr/lib/liballegro_physfs.so
/usr/lib/liballegro.so
/usr/lib/liballegro_font.so
/usr/lib/liballegro_acodec.so
/usr/lib/liballegro_main.so
/usr/lib/liballegro_memfile.so
/usr/lib/liballegro_primitives.so
/usr/lib/liballegro_ttf.so

and `pkg-config --libs allegro-5.0`

see this post for the screenshot.

http://hongouru.blogspot.com/2012/02/solved-allegro5-undefined-reference-to.html

HoNgOuRu
  • 717
  • 4
  • 13
  • 26
  • 1
    You should do it like: `pkg-config --libs allegro-5.0 allegro_dialog-5.0` i.e., List all of the Allegro libs you are using on the pkg-config line. If you link some directly, you may miss dependencies that they rely on. – Matthew Feb 10 '12 at 15:59