Makefile 生成文件代码的问题

Makefile 生成文件代码的问题,makefile,Makefile,当我运行下面的代码时,它会给我一条错误消息: cc1:警告:main.c:不是目录[默认启用] 频繁.o:无法识别文件:无法识别文件格式 collect2:错误:ld返回了1个退出状态 make:[main]错误1 CC = gcc CPPFLAGS = -I main: main.c headers.h sortt.o frequent.o #$(CC) $(CPPFLAGS) -c $^ -o $@ sortt.o: headers.h sortt.c $(CC

当我运行下面的代码时,它会给我一条错误消息:

cc1:警告:main.c:不是目录[默认启用] 频繁.o:无法识别文件:无法识别文件格式 collect2:错误:ld返回了1个退出状态 make:[main]错误1

CC = gcc 
CPPFLAGS = -I 

main: main.c headers.h  sortt.o frequent.o
    #$(CC) $(CPPFLAGS) -c $^ -o $@  
sortt.o:  headers.h sortt.c
    $(CC) $(CPPFLAGS) -c $< -o $@
frequent.o: headers.h frequent_word.c search_similar_word.o
    $(CC) $(CPPFLAGS) -c $< -o $@
CC=gcc
CPPFLAGS=-I
main:main.c headers.h sortt.o frequency.o
#$(CC)$(CPPFLAGS)-c$^-o$@
sortt.o:headers.h sortt.c
$(CC)$(CPPFLAGS)-c$<-o$@
frequent.o:headers.h frequent\u word.c search\u simple\u word.o
$(CC)$(CPPFLAGS)-c$<-o$@

您的规则中有很多错误。为什么
frequency.o
search\u-simple\u-word.o
列为先决条件?没有理由不能在
search\u simple\u word.o
之前或同时构建
frequent.o


另外,您正在使用
$非常感谢,这是我第一次处理make file,但对于search\u similor\u word.o是freq中使用的函数,但这些规则是我的make file代码的一个子部分。。。我会按照你的指导线,我会看到,如果有一个错误呢
CC = gcc 
CPPFLAGS = -I .

main: main.c headers.h  sortt.o frequent.o
        $(CC) $(CPPFLAGS) $^ -o $@  
sortt.o: sortt.c headers.h
        $(CC) $(CPPFLAGS) -c $< -o $@
frequent.o: frequent_word.c headers.h
        $(CC) $(CPPFLAGS) -c $< -o $@