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 <al开发者_C百科legro/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.
I know it's too late to answer this, but there might be someone somewhere seeking for an answer.
the header file is wrong; it should be like this:-
#include <allegro5/allegro.h>
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;
}
精彩评论