[英]Error in makefile, compile multiple C files
我正在尝试创建一个makefile,以便可以编译多个C文件。 此makefile不能按预期工作,并且仅在我运行make all
并给出有关ex3的错误时才编译ex1(请参阅错误日志)
CFLAGS=-Wall -g
all:
make ex1
make ex3
clean:
rm -f ex1
rm -f ex3
错误:
make all
make ex1
make[1]: Entering directory '/home/daniel/ownCloud/code/Learn C the hard way/Make'
cc -Wall -g ex1.c -o ex1
make[1]: Leaving directory '/home/daniel/ownCloud/code/Learn C the hard way/Make'
make ex3
make[1]: Entering directory '/home/daniel/ownCloud/code/Learn C the hard way/Make'
make[1]: *** No rule to make target 'ex3'. Stop.
make[1]: Leaving directory '/home/daniel/ownCloud/code/Learn C the hard way/Make'
Makefile:5: recipe for target 'all' failed
make: *** [all] Error 2
递归调用make
是一个好主意。 您应该按如下所示编写makefile:
CFLAGS=-Wall -g
all: ex1 ex3
clean:
rm -f ex1 ex3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.