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:
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?
You need to link with the allegro libraries that you are using. On Linux, you do this with pkg-config.
]]>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