加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – allegro5 – 如何在Linux上运行?

发布时间:2020-12-16 07:02:46 所属栏目:百科 来源:网络整理
导读:我设置了Allegro 5,并且可以成功编译以下代码: #include stdio.h#include stdlib.h#include string.h#include errno.h#include allegro5/allegro.hvoid error(char *msg){ fprintf(stderr,"%s : %sn",msg,strerror(errno)); exit(1);}int main(int argc,ch
我设置了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 : %sn",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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读