- Online Community Forums » Installation, Setup & Configuration » can't compile after installing

This thread is locked; no one can reply to it. rss feed Print
can't compile after installing
Member #16,628
January 2017

im new to allegro and also compiling with gcc
so, i installed allegro using the ubuntu package liballegro5-dev
now i want to compile this:

1#include <allegro5/allegro.h> 2#include <allegro5/allegro_primitives.h> 3 4int main(int argc, char **argv) { 5 int res[2] = {640, 480}; 6 ALLEGRO_DISPLAY *scr; 7 al_init(); 8 if (! al_init_primitives_addon()) 9 return 1; 10 scr = al_create_display(res[0], res[1]); 11 al_clear_to_color(al_map_rgb(0, 36, 86)); 12 al_draw_circle(res[0]/2, res[1]/2, res[1]/4, al_map_rgb(238, 237, 240), 5); 13 al_flip_display(); 14 while (1); 15 return 0; 16}

using this line:
$ gcc -o allegro_1 -L/usr/lib/x86_64-linux-gnu -lallegro -lallegro_primitives allegro_1.c
but it fails like this:

/tmp/cc5C6cqP.o: In function `main':
allegro_1.c:(.text+0x3d): reference to `al_install_system' not defined
allegro_1.c:(.text+0x42): reference to `al_init_primitives_addon' not defined
allegro_1.c:(.text+0x75): reference to `al_create_display' not defined
allegro_1.c:(.text+0x8d): reference to `al_map_rgb' not defined
allegro_1.c:(.text+0xba): reference to `al_clear_to_color' not defined
allegro_1.c:(.text+0xce): reference to `al_map_rgb' not defined
allegro_1.c:(.text+0x141): reference to `al_draw_circle' not defined
allegro_1.c:(.text+0x146): reference to `al_flip_display' not defined
collect2: error: ld returned 1 exit status

i have no idea what is the problem here
also i dont know if i should add: #include <allegro5/allegro_main.h>
any help, please?

Edgar Reynaldo
Major Reynaldo
May 2007

Member #16,628
January 2017

finally i found i should do like this:
gcc allegro_1.c -o allegro_1 `pkg-config --libs allegro-5 allegro_primitives-5 allegro_main-5`
the order is important. dependencies must go last

Go to: