我已经在这个Makefile上工作了几个小时。它不断得到错误:make:***没有规则来建立目标“ hangman.c”,这是“ hangman.o”所需要的。停止

问题描述 投票:0回答:1
CFLAGS=-std=c99 -Wall
CC=gcc

hangman: hangman.o hangman.c
    $(CC) $(CFLAGS) hangman.o hangman.c -o hangman

hangman.o: hangman.c
    $(CC) $(CFLAGS) -c hangman.c

clean:
    rm -f hangman *.o
c makefile
1个回答
0
投票

尝试一下:

CFLAGS=-std=c99 -Wall
CC=gcc
OBJECTS = hangman.o

all: hangman

hangman.o: hangman.c
    $(CC) $(CFLAGS) -c hangman.c

hangman: $(OBJECTS)
    $(CC) $(OBJECTS) -o hangman

clean:
    rm -f hangman *.o
© www.soinside.com 2019 - 2024. All rights reserved.