构建 Makefile 时遇到错误。它无法在 root/include 目录中找到头文件。这是我的文件结构:
root:
---->include
---->CMSIS:
header files
---->common:
header files
---->MSP432:
heaader files
---->src:
Makefile
C files
Sources.mk
---->linker file
我在 TARGET.out 指令中包含了 -I$(INCLUDES)。这是我的 Makefile:
#******************************************************************************
# Copyright (C) 2017 by Alex Fosdick - University of Colorado
#
# Redistribution, modification or use of this software in source or binary
# forms is permitted as long as the files maintain this copyright. Users are
# permitted to modify this and use it to learn about the field of embedded
# software. Alex Fosdick and the University of Colorado are not liable for any
# misuse of this material.
#
#*****************************************************************************
#------------------------------------------------------------------------------
# <Put a Description Here>
#
# Use: make [TARGET] [PLATFORM-OVERRIDES]
#
# Build Targets:
#
#
# Platform Overrides:
#
#------------------------------------------------------------------------------
include sources.mk
# Platform Overrides
PLATFORM = MSP432
# Architectures Specific Flags
LINKER_FILE = ../msp432p401r.lds
CPU = cortex-m4
ARCH = armv7e-m
FLOAT = hard
FPU = fpv4-sp-d16
SPECS = nosys.specs
TARGET = c1m2
# Compiler Flags and Defines
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
LDFLAGS = -Wl, -Map=$(TARGET).map -T $(LINKER_FILE)
CFLAGS = -mcpu=$(CPU) -mthumb -march=$(ARCH) -mfloat-abi=$(FLOAT) -mfpu=$(FPU) --specs=$(SPECS) -Wall -c -Werror -g -O0 -std=c99
CPPFLAGs = -MD -MP
OBJS = $(SOURCES:.c=.o)
%.o : %.c
$(CC) -I$(INCLUDES) $< $(CFLAGS) -o $@
.PHONY: build
build: all
.PHONY: all
all: $(TARGET).out
$(TARGET).out: $(OBJS)
$(CC) $(OBJS) $(CFLAGS) $(LDFLAGS) -o $@
.PHONY: clean
clean:
rm -f $(OBJS) $(TARGET).out $(TARGET).map
这是我的 Sources.mk。我尝试删除 *.h 但收到相同的错误:
# Add your Source files to this variable
SOURCES = interrupts_msp432p401r_gcc.c \
main.c \
memory.c \
startup_msp432p401r_gcc.c \
system_msp432p401r.c
# Add your include paths to this variable
INCLUDES = ../include/CMSIS \
../include/common \
../include/msp432
输出错误:
arm-none-eabi-gcc main.c -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nosys.specs -Wall -c -Werror -g -O0 -std=c99 -o main.o
main.c:23:22: fatal error: platform.h: No such file or directory
compilation terminated.
Makefile:47: recipe for target 'main.o' failed
make: *** [main.o] Error 1```