Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C Makefile不工作-添加新文件_C_Makefile - Fatal编程技术网

C Makefile不工作-添加新文件

C Makefile不工作-添加新文件,c,makefile,C,Makefile,我正在使用这个预制的makefile。我尝试为我添加到应用程序中的那两个文件添加heavyhitter.o和heavyhitter.h,但我无法让它工作。我添加了metadata_record.h和metadata_record.o,没有问题,因为我正在添加到同一个区域,我不知道为什么它以前可以工作,但现在不行了 CC = $(shell if test -f /opt/local/bin/gcc-mp-4.7; then \ echo gcc-mp-4.7; else echo

我正在使用这个预制的makefile。我尝试为我添加到应用程序中的那两个文件添加heavyhitter.o和heavyhitter.h,但我无法让它工作。我添加了metadata_record.h和metadata_record.o,没有问题,因为我正在添加到同一个区域,我不知道为什么它以前可以工作,但现在不行了

CC = $(shell if test -f /opt/local/bin/gcc-mp-4.7; then \ echo gcc-mp-4.7; else echo gcc; fi) CFLAGS = -std=gnu99 -g -W -Wall -O0 -gstabs -Iglib-2.0 -lglib-2.0 TESTS = $(patsubst %.c,%,$(sort $(wildcard test[0-9][0-9][0-9].c))) %.o: %.c m61.h memory.h metadata_record.h heavyhitters.h $(CC) $(CFLAGS) -o $@ -c $ all: $(TESTS) hhtest @echo "*** Run 'make check' or 'make check-all' to check your work." test%: test%.o m61.o memory.o metadata_record.o heavyhitters.o $(CC) $(CFLAGS) -o $@ $^ test017: test017-help.o hhtest: hhtest.o m61.o memory.o metadata_record.o heavyhitters.o $(CC) $(CFLAGS) -o $@ $^ -lm check: $(TESTS) $(patsubst %,check-%,$(TESTS)) @echo "*** All tests succeeded!" check-all: $(TESTS) @x=true; for i in $(TESTS); do $(MAKE) check-$$i || x=false; done; \ if $$x; then echo "*** All tests succeeded!"; fi; $$x check-test%: test% @test -d out || mkdir out @rm -f out/test$*.fail @-sh -c "./$^ > out/test$*.output 2>&1" >/dev/null 2>&1; true @perl compare.pl out/test$*.output test$*.c test$* clean: rm -f $(TESTS) hhtest *.o rm -rf out MALLOC_CHECK_=0 export MALLOC_CHECK_ .PRECIOUS: %.o .PHONY: all clean check check-% prepare-check CC=$(如果测试为-f/opt/local/bin/gcc-mp-4.7,则为shell;然后\ echo gcc-mp-4.7;其他echo gcc;fi) CFLAGS=-std=gnu99-g-W-Wall-O0-gstabs-Iglib-2.0-lglib-2.0 TESTS=$(patsubst%.c,%,$(sort$(通配符测试[0-9][0-9][0-9].c))) %.o:%.c m61.h memory.h metadata_record.h heavyhitters.h $(CC)$(CFLAGS)-o$@-c$ 全部:$(测试)hhtest @echo“***运行“检查”或“全部检查”检查您的工作。” test%:test%.o m61.o内存.o元数据_记录.o重文件.o $(CC)$(CFLAGS)-o$@$^ test017:test017 help.o hhtest:hhtest.o m61.o memory.o metadata_record.o heavyhitters.o $(CC)$(CFLAGS)-o$@$^-lm 检查:$(测试)$(patsubst%,检查-%,美元(测试)) @echo“***所有测试均成功!” 全部选中:$(测试) @x=真;对于i,单位为美元(测试);do$(MAKE)check-$$i | | x=false;完成\ 如果$$x;然后回显“***所有测试成功!”;fi$$x 检查测试%:测试% @测试-d输出| | mkdir输出 @rm-f输出/测试$*。失败 @-sh-c“/$^>输出/测试$*。输出2>&1”>/dev/null 2>&1;真的 @perl compare.pl out/test$*.output test$*.c test$* 清洁: rm-f$(测试)hhtest*.o rm-rf输出 MALLOC_检查=0 导出MALLOC\u检查_ .珍贵:% .虚假:所有清洁支票-%准备支票
实际上,它应该是heavyhitter而不是heavyhitters

使用
remake
并运行
remake-x
甚至
remake-x-d
来调试
Makefile
以什么方式不起作用?我得到“make:**没有规则生成目标
hevyHitters.o”,这是
test001.需要的。停止。”我的系统上没有“重做”命令。您添加的文件是否与其他源文件位于同一文件夹中?如果没有,您可能需要调整make的sources选项以查找它们,或者通过相对路径或绝对路径(请不要使用后者)指定它们。它们位于同一目录中