我试着用另外两个最相关的主题来解决这个问题:Makefile error: No rule to make target Makefile: No rule to make target. Stop
但这两个似乎都没有解决我的问题。
我不确定我的代码哪里出了问题,因为我的讲师验证了代码在他那端可以正常工作。
我的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.如图所示,image
我正在尝试编译的程序的实际代码只有4行。我不认为这是问题的原因
#include <stdio.h>
char *msg = "Exam Lab 1";
int main(int argc, char *argv[]) {
printf("%s\n", msg);
}下面是我运行make的目录的内容:

发布于 2016-07-08 04:13:02
您的makefile没有正确的名称。
默认情况下,make查找名为makefile或Makefile的文件。你的文件名为Makefile.txt,所以make找不到它。
将名称更改为makefile或Makefile,或者使用-f选项指定makefile名称,例如。make -f Makefile.txt。
发布于 2016-07-08 04:13:23
从您提供的图像中可以清楚地看出,您已经将该文件命名为Makefile.txt。正如@dbus.所说,makefile必须命名为Makefile或makefile。默认情况下,这些是唯一要查找的文件名。
否则,您必须运行make -f Makefile.txt。
https://stackoverflow.com/questions/38253951
复制相似问题