简体   繁体   English

allegro5 - 如何在Linux上运行?

[英]allegro5 - How to run on Linux?

I set up Allegro 5, and could compile the following code with success: 我设置了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;
}

But after running it, it failed with the error message: 但运行后,它失败并显示错误消息:

Could not initailize allegro : No such file or directory. 无法启动allegro:没有这样的文件或目录。

I don't know what is wrong. 我不知道出了什么问题。 My OS is Ubuntu, I'd compiled the code successfully with: 我的操作系统是Ubuntu,我用以下代码成功编译了代码:

gcc try.c -lallegro 

But could not run it with: 但无法运行它:

./a.out

Allegro needs a configuration file and possibly other files to operate. Allegro需要配置文件以及可能的其他文件才能运行。 From your comment, that is probably why it is not working. 从您的评论中,这可能就是为什么它不起作用。 From the readme: 从自述文件:

"

Normally the setup program and allegro.cfg will go in the same directory as the Allegro program they are controlling. 通常,安装程序和allegro.cfg将与他们控制的Allegro程序位于同一目录中。 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. 这对最终用户来说很好,但对于使用Allegro的程序员来说这可能是一件痛苦的事情,因为你可能在不同的目录中有几个程序,并希望对所有这些程序使用一个allegro.cfg。 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. 如果是这种情况,您可以将环境变量ALLEGRO设置为包含allegro.cfg的目录,如果当前目录中没有allegro.cfg,Allegro将查看该目录。

... ...

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/. 在Unix,BeOS和MacOS X下,配置文件例程也按顺序检查〜/ allegro.cfg,〜/ .allegrorc,/ etc /allegro.cfg和/ etc / allegrorc,键盘和语言文件可以存储在您的主目录或/ etc /中。

See more: 查看更多:

http://alleg.sourceforge.net/stabledocs/en/readme.html#configuration http://alleg.sourceforge.net/stabledocs/en/readme.html#configuration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM