简体   繁体   English

为什么不能通过使用$来识别Makefile中规则的右侧?

[英]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.

相关问题 规则在Makefile中无法识别? - Rule not recognized in makefile? 为什么静态模式规则在我的 makefile 中不起作用 - Why isn't the Static Pattern Rule working in my makefile 逻辑运算符的右手操作数 || 由于调用 function(MISRA-C 2012Rule 13.5)而具有持续的副作用 - The right hand operand of a logical operator || has persistent side effects because of calling function (MISRA- C 2012Rule 13.5) “ &amp;&amp;”或“ ||”的右操作数 是可能有副作用的表达 - Right hand operand of '&&' or '||' is an expression with possible side effects 将首先评估表达式的右侧 - will right hand side of an expression always evaluated first Makefile找不到规则 - Makefile doesn't find the rule 在规则中使用 makefile 文件作为先决条件 - Using makefile file as prerequisite in a rule 如何从屏幕右侧而不是 C 中通常的左侧按 output 进行打印? - How to print by output from the right hand side of the screen instead of the usual left hand side in C? 为什么我的简单 makefile 只打印规则? - Why is my simple makefile only printing the rule? 在带有指针变量的表达式右侧使用逻辑非运算符(两次) - Use of logical not operator (twice) on right hand side of expression with pointer variable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM