使用 makefile 构建的文件消失(包括二进制文件)

使用 makefile 构建的文件消失(包括二进制文件)

我正在 TS-7800(SBC) 上构建一个程序,当我运行 make(如下所示)时,它似乎正常执行了所有步骤,但最后我没有得到二进制文件。这是为什么?我该如何获取我的文件?

生成文件

CC= /home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc 

# compiler options

#CFLAGS= -O2
CFLAGS= -mcpu=arm9 
#CFLAGS= -pg -Wall

# linker

LN= $(CC)

# linker options

LNFLAGS= 
#LNFLAGS= -pg

# extra libraries used in linking (use -l command)

LDLIBS= -lpthread

# source files

SOURCES= HMITelem.c Cpacket.c GPS.c ADC.c Wireless.c Receivers.c CSVReader.c RPM.c RS485.c

# include files

INCLUDES= Cpacket.h HMITelem.h CSVReader.h RS485.h

# object files

OBJECTS= HMITelem.o Cpacket.o GPS.o ADC.o Wireless.o Receivers.o CSVReader.o RPM.o RS485.o

HMITelem: $(OBJECTS)
    $(LN) $(LNFLAGS) -o $@ $(OBJECTS) $(LDLIBS)

.c.o:   $*.c
    $(CC) $(CFLAGS) -c $*.c

RUN : ./HMITelem

#clean:
#   rm -f *.o
#   rm -f *~

输出

root@ts7800:ReidTest# make
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c HMITelem.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c Cpacket.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c GPS.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c ADC.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c Wireless.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c Receivers.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c CSVReader.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c RPM.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc  -mcpu=arm9  -c RS485.c
/home/eclipse/ReidTest/cc/cross-toolchains/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc   -o HMITelem HMITelem.o Cpacket.o GPS.o ADC.o Wireless.o Receivers.o CSVReader.o RPM.o RS485.o -lpthread

谢谢。

答案1

隐含的制作将源代码编译成目标文件的规则似乎有问题。没有与“cc -c xc”配合使用的输出规范“-o xo”。运行 make 后是否有任何目标文件?

.c.o:   $*.c

另外,上面的目标规范“.co”对我来说看起来很奇怪;也许制作也无法识别这一点,这就解释了为什么不应用制作目标文件的隐式规则。

这可能是对象规则的更好的目标规范和先决条件(直接来自 GNU‘make’手册):

$(OBJECTS): %.o: %.c
        $(CC) -c $(CFLAGS) $< -o $@

答案2

.co 只有在没有先决条件时才是特殊的(后缀规则),在这种情况下,每个 .c 文件都是相应 .o 文件的隐式先决条件。如果有先决条件,make 会尝试构建名为 .co 的文件!请参阅http://www.gnu.org/software/make/manual/html_node/Suffix-Rules.html

相关内容