我的makefile怎么了?
CC = gcc
OBJS = main.o map.o extended_map.o election.o utilities.o
EXEC = election
DEBUG_FLAG = -DNDEBUG
COMP_FLAG = -std=c99 -Wall -pedantic-errors -Werror
$(EXEC) : $(OBJS)
$(CC) $(DEBUG_FLAG) $(OBJS) -o $@
main.o: main.c map.h election.h test_utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
map.o: map.c map.h utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
extended_map.o: extended_map.c extended_map.h map.h utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
election.o: election.c election.h map.h extended_map.h utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
utilities.o: utilities.c utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
clean:
rm -f $(OBJS) $(EXEC)
我正在linux上运行以下命令:
-bash-4.2$ ls
election.c extended_map.c main.c makefile mtm_map utilities.c
election.h extended_map.h main.o map.h test_utilities.h utilities.h
-bash-4.2$ make
make: *** No rule to make target `map.c', needed by `map.o'. Stop.
-bash-4.2$
map.c存在于当前文件夹中名为mtm_map
的文件夹中
您告诉了make如何从“ map.c”中构建“ map.o”,但是您没有“ map.c”。您有“ mtm_map / map.c”。
您可能想要类似的东西
CC = gcc
OBJS = main.o mtm_map/map.o extended_map.o election.o utilities.o
EXEC = election
DEBUG_FLAG = -DNDEBUG
COMP_FLAG = -std=c99 -Wall -pedantic-errors -Werror
$(EXEC) : $(OBJS)
$(CC) $(DEBUG_FLAG) $(OBJS) -o $@
main.o: main.c map.h election.h test_utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
mtm_map/map.o: mtm_map/map.c map.h utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
extended_map.o: extended_map.c extended_map.h map.h utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
election.o: election.c election.h map.h extended_map.h utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
utilities.o: utilities.c utilities.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
clean:
rm -f $(OBJS) $(EXEC)