c++linuxcodeblocksallegro

what I'm including wrong ? undefined reference to al_init_image_addon error,


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;
}

Solution

  • 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