我尝试使用其他两个最相关的主题来解决这个问题:
Makefile error: No rule to make target
Makefile: No rule to make target. Stop
但是,似乎都没有解决我的问题。
我不确定我的代码哪里出错了,因为我的教练确认了他那边的代码是可以工作的。
我的makefile代码如下:
然而,当我尝试执行“make run”时,会产生以下结果。
这是我运行
我不确定我的代码哪里出错了,因为我的教练确认了他那边的代码是可以工作的。
我的makefile代码如下:
TARGET = demo
FILES = test.c
OBJS = $(FILES:.c=.o)
ASMS = $(FILES:.c=.s)
all: $(TARGET)
$(TARGET): $(OBJS)
gcc -o $@ $^
%.o: %.c
gcc -c $< -o $@
%.s: %.c
gcc -S -masm=intel $< -o $@
asm: $(ASMS)
run: $(TARGET)
./$(TARGET)
clean:
rm -f $(TARGET) $(OBJS) $(ASMS)
然而,当我尝试执行“make run”时,会产生以下结果。
make: *** No rule to make target 'run'. Stop.
如图所示图像
我尝试编译的程序实际上只有4行代码,我不认为这是问题的原因。
#include <stdio.h>
char *msg = "Exam Lab 1";
int main(int argc, char *argv[]) {
printf("%s\n", msg);
}
这是我运行
make
的目录内容:
make
命令的目录中包含哪些内容?应该有名为Makefile
或makefile
的 makefile 文件和 .c 文件。 - dbushmake -v
来查找)。 - dbush