[英]Why can't the right hand side of a rule in Makefile be recognized by using $?
So I created a rule to convert all .c files to .o files. 所以我创建了一个将所有.c文件转换为.o文件的规则。 I used variable
$
to place the right hand side of the rule into the recipe. 我使用变量
$
将规则的右侧放入配方中。 The left hand side is ok with $@, but the right hand side is empty. $ @的左侧是好的,但右侧是空的。 I remember I did a similar Makefile with
$
, and it worked. 我记得我用
$
做了一个类似的Makefile,它有效。
CFLAGS =-c -g
all:server client
server:server.o
gcc -o server server.o
client:client.o
gcc -o client client.o
clean:
rm *.o server client
%.o:%.c
gcc ${CFLAGS} -o $@ $
server.o : server.c
client.o : client.c
Should be $<
, not simply $
. 应该是
$<
,而不仅仅是$
。 See info "(make) Automatic Variables"
. 请参阅
info "(make) Automatic Variables"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.