Compiling C ++ code with alebro 5 and g ++

What flags do i need to add in g ++ to compile code with allegro 5? I tried

g++ allegro5test.cpp -o allegro5test `allegro-config --libs`

but it does not work. I am using ubuntu 11.04. I installed allegro 5 using the instructions http://wiki.allegro.cc/index.php?title=Install_Allegro5_From_SVN/Linux/Debian

I tried:

g++ allegro5test.cpp -o allegro5test `allegro-config --cflags --libs`

And it also gives a bunch of undefined errors, for example: undefined reference to `al_install_system '

allegro-config --cflags --libs outputs:

-I/usr/local/include
-L/usr/local/lib -lalleg
+3
source share
2 answers

, allegro5 SVN. , , , allegro-config. , , allegro4.

allegro5 , , .

:

#include <stdio.h>
#include <allegro5/allegro.h>

int main(int argc, char **argv)
{
   ALLEGRO_DISPLAY *display = NULL;

   if(!al_init()) {
      fprintf(stderr, "failed to initialize allegro!\n");
      return -1;
   }

   display = al_create_display(640, 480);
   if(!display) {
      fprintf(stderr, "failed to create display!\n");
      return -1;
   }

   al_clear_to_color(al_map_rgb(0,0,0));
   al_flip_display();
   al_rest(10.0);
   al_destroy_display(display);
   return 0;
}

, , :

g++ hello.cpp -o hello -I/usr/include/allegro5 -L/usr/lib -lallegro
+5

Allegro 5 pkg-config.

pkg-config --libs allegro-5.0 allegro_image-5.0

, .

+3

All Articles