makefile使用C源文件生成致命错误“不知道如何制作目标”的问题

时间:2015-02-27 14:35:45

标签: c unix makefile

我遇到了这个makefile的问题,给出了致命错误:"不知道如何制作目标calc.o"。命名是正确的,并且在工作目录中,另一个问题是,当我切换目标文件的顺序为默认目标文件时,它会说它不知道如何制作该目标,所以订单不似乎改变了什么或是一个特定的文件。我也在sun sparc unix服务器上运行make命令。 makefile粘贴在下面:

#The following rule tells make about possible suffixes
#(extensions) of file names.
.SUFFIXES: .c .o
#The following definition of CC ensures that
#gcc will be used to compile the C source files.
CC = gcc
#The following definition of CFLAGS ensures that
#the debugger can be used with the executable file (p1)
#created by running make.
CFLAGS = -g
#The following rule tells make how a ".o" file should
#be created from the corresponding ".c" file.
#Note that the "-c" option must be used here since we are
#compiling source files separately. (Note that the line
#following the ".c.o:" line begins with the "tab" character.)
.c.o:
    $(CC) $(CFLAGS) -c $<
#Dependency rule for the default target and how the
#default target is to be created. (Note that the line
#following the dependency rule begins with the "tab"
#character.)
p2: main.o textToBin.o binToText.o calc.o
    gcc main.o textToBin.o binToText.o calc.o -o p2
#Dependency rules for other targets. (We don't need to
#specify how these targets are created since we have already
#given a general rule for creating a ".o" file from the
#corresponding ".c" file.)
#NO HEADER FILES
#Target for removing unnecessary files.
clean:
    rm -f *.o core

0 个答案:

没有答案