Errores al compilar el programa de biblioteca allegro en gcc

Errores al compilar el programa de biblioteca allegro en gcc

Intenté instalar la biblioteca allegro en mi sistema. No recibí ningún error al instalar la biblioteca, pero parece que algo salió mal durante la instalación. Mi código junto con los errores que recibo al compilar el programa:

    /* testprog.c */

#include <allegro.h>

void init();
void deinit();

int main() {
init();

while (!key[KEY_ESC]) {
/* put your code here */
}

deinit();
return 0;
}
END_OF_MAIN()

void init() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if (res != 0) {
allegro_message(allegro_error);
exit(-1);
}

install_timer();
install_keyboard();
install_mouse();
/* add other initializations here */
}

void deinit() {
clear_keybuf();
/* add other deinitializations here */
}


Errors I'm getting:

$ gcc testprog.c -o testprog `allegro-config --cflags --libs`
testprog.c: In function ‘init’:
testprog.c:26:1: warning: format not a string literal and no format arguments [-Wformat-security]
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
$

Seguí las instrucciones proporcionadas en estos enlaces para instalar la biblioteca y compilar mi programa:

Instrucciones para instalar allegro en ubuntu

Instrucciones para compilar programas escritos en allegro.

Respuesta1

allegro_message()genera un mensaje, utilizando una printf()cadena de formato.

El error está en la línea:

allegro_message(allegro_error);

Cámbielo a:

allegro_message("%s\n", allegro_error);

información relacionada