gcc에서 allegro 라이브러리 프로그램을 컴파일하는 중 오류가 발생했습니다.

gcc에서 allegro 라이브러리 프로그램을 컴파일하는 중 오류가 발생했습니다.

시스템에 allegro 라이브러리를 설치해 보았습니다. 라이브러리를 설치하는 동안 오류는 발생하지 않았지만 설치 중에 문제가 발생한 것 같습니다. 내 코드와 프로그램을 컴파일하는 동안 발생하는 오류는 다음과 같습니다.

    /* 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
$

라이브러리를 설치하고 프로그램을 컴파일하기 위해 다음 링크에 제공된 지침을 따랐습니다.

우분투에 allegro 설치 지침

알레그로로 작성된 프로그램 컴파일 지침

답변1

allegro_message()형식 문자열 을 사용하여 메시지를 출력합니다 printf().

오류는 다음 줄에 있습니다.

allegro_message(allegro_error);

다음으로 변경하세요.

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

관련 정보