#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));al_flip_display();al_rest(10.0);al_destroy_display(display);return 0;}
但运行后,它失败并显示错误消息:
Could not initailize allegro : No such file or directory.
我不知道出了什么问题.我的 *** 作系统是Ubuntu,我用以下代码成功编译了代码:
gcc try.c -lallegro
但无法运行它:
./a.out解决方法 Allegro需要配置文件以及可能的其他文件才能运行.从您的评论中,这可能就是为什么它不起作用.从自述文件:
“
normally the setup program and allegro.cfg will go in the same directory as the Allegro program they are controlling. This is fine for the end user,but it can be a pain for a programmer using Allegro because you may have several programs in different directorIEs and want to use a single allegro.cfg for all of them. If this is the case you can set the environment variable ALLEGRO to the directory containing your allegro.cfg,and Allegro will look there if there is no allegro.cfg in the current directory.
…
Under Unix,BeOS and MacOS X,the config file routines also check for ~/allegro.cfg,~/.allegrorc,/etc/allegro.cfg,and /etc/allegrorc,in that order,and the keyboard and language files can be stored in your home directory or in /etc/.
看更多:
http://alleg.sourceforge.net/stabledocs/en/readme.html#configuration
总结以上是内存溢出为你收集整理的c – allegro5 – 如何在Linux上运行?全部内容,希望文章能够帮你解决c – allegro5 – 如何在Linux上运行?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)