[英]Makefile for compiling Allegro5 c program
I wrote a little game in c using Allegro 5 library. 我使用Allegro 5库在C语言中编写了一个小游戏。 I need to compile and run it on a generic linux environment, so i try to do a makefile for easy compiling it.
我需要在通用的linux环境下进行编译和运行,因此我尝试制作一个makefile以便于对其进行编译。
CFLAGS = -Wall -c
EFLAGS =
EOPTION = `pkg-config --cflags --libs allegro-5.0 allegro_primitives-5.0 allegro_font-5.0 allegro_audio-5.0 allegro_ttf-5.0 allegro_image-5.0 allegro_acodec-5.0` -lm
OBJFOLD = objectfiles
SOURCE = #all my source codes.
OBJECT = #all my object files.
EXC = Foo
all: $(SOURCE) $(EXC)
$(EXC): $(OBJECT)
gcc $(EFLAGS) -o $(EXC) $(OBJECT) $(EOPTION)
$(OBJFOLD)/%.o: %.c
gcc $(CFLAGS) $< -o $@
$(OBJFOLD)/%.o: libraries/%.c
gcc $(CFLAGS) $< -o $@
It works fine on my computer in which i installed Allegro 5 library, but i need it works on a Linux Os just running the make files (so without installing Allegro 5 every time). 它在我安装了Allegro 5库的计算机上运行良好,但是我需要它在仅运行make文件的Linux Os上运行(因此无需每次都安装Allegro 5)。 My project folder's struct is:
我的项目文件夹的结构是:
- Project
-allegro5
-bin
-fonts
-images
-include
-libraries
-objectfiles
-sounds
So, I added to $(OBJFOLD)/%.o target's instruction the option '-Iallegro5/include' but when I try to run the makefile, it return: 因此,我在$(OBJFOLD)/%。o目标的指令中添加了选项'-Iallegro5 / include',但是当我尝试运行makefile时,它返回:
$ make -f Makefile
gcc -Wall -c Main.c -o objectfiles/Main.o -Iallegro5/include
In file included from allegro5/include/allegro5/internal/alconfig.h:35:0,
from allegro5/include/allegro5/base.h:50,
from allegro5/include/allegro5/allegro.h:26,
from Main.c:3:
allegro5/include/allegro5/platform/almngw32.h:23:20: fatal error: direct.h: No such file or directory
#include "allegro5/platform/alplatf.h"
^
compilation terminated.
I think I am on a totally wrong way, so can someone help me? 我认为我的做法完全错误,有人可以帮助我吗?
I'm now working on a Cygwin environment on my Windows pc, and i download my "allegro5" folder from here . 我现在正在Windows PC上使用Cygwin环境,并从此处下载“ allegro5”文件夹。 I prefer to solve it using a makefile.
我更喜欢使用makefile解决它。
Shouldn't it be -Iallegro5/include?? 应该不是-Iallegro5 / include吗? (capital i, not small L)
(大写i,不小L)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.