makefile错误“没有规则可以成为目标"怎么解决呢? [英] makefile error "No rule to make target" how to solve it?
本文介绍了makefile错误“没有规则可以成为目标"怎么解决呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的makefile有什么问题?
what's wrong with my 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上运行以下命令:
I am running the following command on 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
的文件夹中
map.c exists inside a folder named mtm_map
inside the current folder
推荐答案
您告诉了make如何从"map.c"中构建"map.o",但是您没有"map.c".您有"mtm_map/map.c".
You told make how to build "map.o" out of "map.c", but you don't have "map.c". You have "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)
这篇关于makefile错误“没有规则可以成为目标"怎么解决呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文