Search code examples
allegroallegro5

Compiling Allegro 5.0 libs on ubuntu: "undefined reference to ..."


I'm new to Allegro, Ubuntu, and C++ ... sorry in advance...

I just installed Allegro 4. Something from the ubuntu software manager. I then followed the directions of this page to install Allegro 5. I don't think my libs are linked correctly, but I don't exactly know how to manually change that.

My code:

#include <allegro.h> //the allegro 4 header?
#include <allegro/allegro5.h> //the allegro 5 header?

int main(){
    allegro_init();
}

END_OF_MAIN()

My compile line:

g++ allegro_test.cpp -o output.out `pkg-config --libs allegro5.0`

My output:

allegro_test.cpp (.text+0x2a) undefined refrence to '_install_allegro_check_version'

I assume it is similar to this question, but I cannot figure out how to get the library linked. I'd like to have it know automatically.


Solution

  • From the question you linked:

    gcc foo.c -o foo $(pkg-config --libs allegro-5.0)
    

    However, the source code you've posted is Allegro 4. Allegro 5 is not backward compatible. The A5 equivalent is:

    #include <allegro/allegro5.h>
    
    int main() {
       al_init();
       return 0;
    }