我安装了 Allegro 5,并且能够成功编译以下代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <allegro5/allegro.h>
void error(char *msg)
{
fprintf(stderr,"%s : %s\n", msg, strerror(errno));
exit(1);
}
int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display = NULL;
if(!al_init())
error("Could not initailize allegro");
display = al_create_display(640, 480);
if(!display)
error("fail to display");
al_clear_to_color(al_map_rgb(0,0,0));
al_flip_display();
al_rest(10.0);
al_destroy_display(display);
return 0;
}
但是在运行程序后,出现了错误信息:
无法初始化allegro:没有这个文件或目录。
我不知道问题出在哪里。我的操作系统是Ubuntu,在终端上编译代码时没有出错:
gcc try.c -lallegro
但是无法运行它:
./a.out
strace ./a.out
以查看它无法找到什么。 - James Mpkg-config
而不是-lallegro
。无论如何,请编译 Allegro 的调试版本并检查 allegro.log。 - Matthew