make collect2.exe:错误:ld返回1退出状态错误

发布于 2025-02-08 21:31:55 字数 8349 浏览 1 评论 0原文

我有这个makefile,当我与make cygwin进行编译时,它说: 制作:collect2.exe:错误:ld返回1退出状态

######################################
# target
######################################
TARGET = blinkingled


######################################
# building variables
######################################
# debug build?
#DEBUG = 1
# optimization
OPT = -Og


#######################################
# paths
#######################################
# Build path
BUILD_DIR = build

######################################
# source
######################################
# C sources
SRCS      = main_cm0plus.c
SRCS      += system_tviibe1m_cm0plus.c
SRCS      += startup.c
SRCS      += $(wildcard src/drivers/adc/*.c)
SRCS      += $(wildcard src/drivers/canfd/*.c)
SRCS      += $(wildcard src/drivers/cpu/*.c)
SRCS      += $(wildcard src/drivers/crypto/*.c)
SRCS      += $(wildcard src/drivers/dma/*.c)
SRCS      += $(wildcard src/drivers/evtgen/*.c)
SRCS      += $(wildcard src/drivers/flash/*.c)
SRCS      += $(wildcard src/drivers/gpio/*.c)
SRCS      += $(wildcard src/drivers/ipc/*.c)
SRCS      += $(wildcard src/drivers/lin/*.c)
SRCS      += $(wildcard src/drivers/lvd/*.c)
SRCS      += $(wildcard src/drivers/mcwdt/*.c)
SRCS      += $(wildcard src/drivers/mpu/*.c)
SRCS      += $(wildcard src/drivers/prot/*.c)
SRCS      += $(wildcard src/drivers/scb/*.c)
SRCS      += $(wildcard src/drivers/smartio/*.c)
SRCS      += $(wildcard src/drivers/srom/*.c)
SRCS      += $(wildcard src/drivers/sysclk/*.c)
SRCS      += $(wildcard src/drivers/sysflt/*.c)
SRCS      += $(wildcard src/drivers/sysint/*.c)
SRCS      += $(wildcard src/drivers/syslib/*.c)
SRCS      += $(wildcard src/drivers/syspm/*.c)
SRCS      += $(wildcard src/drivers/sysreset/*.c)
SRCS      += $(wildcard src/drivers/sysrtc/*.c)
SRCS      += $(wildcard src/drivers/systick/*.c)
SRCS      += $(wildcard src/drivers/syswdt/*.c)
SRCS      += $(wildcard src/drivers/tcpwm/*.c)
SRCS      += $(wildcard src/drivers/trigmux/*.c)
SRCS      += $(wildcard src/interrupts/rev_d/*.c)
SRCS      += $(wildcard src/mw/button/*.c)
SRCS      += $(wildcard src/mw/flash/*.c)
SRCS      += $(wildcard src/semihosting/*.c)
SRCS      += $(wildcard src/swtimer/*.c)
SRCS      += $(wildcard src/startup/*.c)
SRCS      += $(wildcard src/system/*.c)

# ASM sources
ASM_SOURCES =  "C:/data/traveo/TVII_Sample_Driver_Library_7.1.0/tviibe1m/src/startup_cm0plus.s"
#startup_cm0plus.s 


#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
 
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m0plus

# fpu
FPU = -mfpu=fpv4-sp-d16

# float-abi
FLOAT-ABI = -mfloat-abi=soft

# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

# macros for gcc
# AS defines
AS_DEFS = 

# C defines
#C_DEFS = ../../


# AS includes
AS_INCLUDES = 

# C includes

INCDIRS = ../../common/hdr
INCDIRS += ../../common/hdr/cmsis/include
INCDIRS += ../../common/src/drivers
INCDIRS += ../../common/src/drivers/sysclk
INCDIRS += ../../common/src/drivers/flash
INCDIRS += ../../common/src/drivers/syslib
INCDIRS += ../../common/src/drivers/mcwdt
INCDIRS += ../../tviibe1m/hdr/rev_d
INCDIRS += ../../tviibe1m/hdr/rev_d/ip
INCDIRS += ../../tviibe1m/src/system/rev_d
INCDIRS += ../../tviibe1m/hdr/rev_d/mcureg
INCDIRS += ../../tviibe1m/src/drivers/
INCDIRS += ../../common/src/drivers/syswdt
INCDIRS += ../../common/src/mw

INCLUDE   = $(addprefix -I,$(INCDIRS))

# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif

# My C flags:
CFLAGS += -Wno-unused-variable

# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"


#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = "c:/data/traveo/TVII_Sample_Driver_Library_7.1.0/tviibe1m/src/linker.ld"

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = 
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections

# default action: build all


all: $(TARGET)
blinkingled: main_cm0plus.o system_tviibe1m_cm0plus.o startup.o
    $(CC) $^ -o $@
    
    
main_cm0plus.o: main_cm0plus.c 
    $(CC) $(CFLAGS) main_cm0plus.c
    
system_tviibe1m_cm0plus.o: system_tviibe1m_cm0plus.c cy_project.h cy_device_headers.h 
    $(CC) $(CFLAGS) system_tviibe1m_cm0plus.c
    
    
startup.o: startup.c startup_customize.h
    $(CC) $(CFLAGS) startup.c
    
BIN_NAME  = $(addprefix $(BUILD_DIR), $(TARGET))

.PHONY: all
all: $(BIN_NAME).elf
all: $(BIN_NAME).bin
all: $(BIN_NAME).s19
all: $(BIN_NAME).hex
all: $(BIN_NAME).lst
all: print_size


%.bin: %.elf
    $(CP) -O binary -S $< $@

%.s19: %.elf
    $(CP) -O srec -S $< $@

%.hex: %.elf
    $(OBJCOPY) -O ihex -S $< $@

%.lst: %.elf
    $(CP) -d $< > $@

.PHONY: print_size
print_size: $(BIN_NAME).elf
    $(SIZE) $<



#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))

$(BUILD_DIR)/%.o: %.c makefile | $(BUILD_DIR) 
    $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.s makefile | $(BUILD_DIR)
    $(AS) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) makefile
    $(CC) $(OBJECTS) $(LDFLAGS) -o $@
    $(SZ) $@

$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
    $(HEX) $< $@
    
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
    $(BIN) $< $@    
    
$(BUILD_DIR):
    mkdir $@        

#######################################
# clean up
#######################################
clean:
    -rm -fR $(BUILD_DIR)
  
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

# *** EOF ***

错误:

c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-no
ne-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x18): undefined reference to `_exit'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\cygwin64\tmp\ccHNkyd5.o: in function `main':
main_cm0plus.c:(.text.main+0x2): undefined reference to `SystemInit'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: main_cm0plus.c:(.text.main+0xa): undefined reference to `Cy_SysEn
ableApplCore'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: main_cm0plus.c:(.text.main+0x14): undefined reference to `Cy_GPIO
_Pin_Init'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: main_cm0plus.c:(.text.main+0x1a): undefined reference to `Cy_SysT
ick_DelayInUs'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: main_cm0plus.c:(.text.main+0x28): undefined reference to `__cm4_v
ector_base_linker_symbol'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:173: main_cm0plus.o] Error 1

有人知道如何解决此问题吗? 我正在尝试从这个makefile产生十六进制和精灵。 另外,我将感谢Makefile上的任何提示/更正。我试图眨眼一个LED,但我对Makefiles的手臂开发非常新 谢谢

I have this makefile and when I compile with make cygwin it says:
make: collect2.exe: error: ld returned 1 exit status

######################################
# target
######################################
TARGET = blinkingled


######################################
# building variables
######################################
# debug build?
#DEBUG = 1
# optimization
OPT = -Og


#######################################
# paths
#######################################
# Build path
BUILD_DIR = build

######################################
# source
######################################
# C sources
SRCS      = main_cm0plus.c
SRCS      += system_tviibe1m_cm0plus.c
SRCS      += startup.c
SRCS      += $(wildcard src/drivers/adc/*.c)
SRCS      += $(wildcard src/drivers/canfd/*.c)
SRCS      += $(wildcard src/drivers/cpu/*.c)
SRCS      += $(wildcard src/drivers/crypto/*.c)
SRCS      += $(wildcard src/drivers/dma/*.c)
SRCS      += $(wildcard src/drivers/evtgen/*.c)
SRCS      += $(wildcard src/drivers/flash/*.c)
SRCS      += $(wildcard src/drivers/gpio/*.c)
SRCS      += $(wildcard src/drivers/ipc/*.c)
SRCS      += $(wildcard src/drivers/lin/*.c)
SRCS      += $(wildcard src/drivers/lvd/*.c)
SRCS      += $(wildcard src/drivers/mcwdt/*.c)
SRCS      += $(wildcard src/drivers/mpu/*.c)
SRCS      += $(wildcard src/drivers/prot/*.c)
SRCS      += $(wildcard src/drivers/scb/*.c)
SRCS      += $(wildcard src/drivers/smartio/*.c)
SRCS      += $(wildcard src/drivers/srom/*.c)
SRCS      += $(wildcard src/drivers/sysclk/*.c)
SRCS      += $(wildcard src/drivers/sysflt/*.c)
SRCS      += $(wildcard src/drivers/sysint/*.c)
SRCS      += $(wildcard src/drivers/syslib/*.c)
SRCS      += $(wildcard src/drivers/syspm/*.c)
SRCS      += $(wildcard src/drivers/sysreset/*.c)
SRCS      += $(wildcard src/drivers/sysrtc/*.c)
SRCS      += $(wildcard src/drivers/systick/*.c)
SRCS      += $(wildcard src/drivers/syswdt/*.c)
SRCS      += $(wildcard src/drivers/tcpwm/*.c)
SRCS      += $(wildcard src/drivers/trigmux/*.c)
SRCS      += $(wildcard src/interrupts/rev_d/*.c)
SRCS      += $(wildcard src/mw/button/*.c)
SRCS      += $(wildcard src/mw/flash/*.c)
SRCS      += $(wildcard src/semihosting/*.c)
SRCS      += $(wildcard src/swtimer/*.c)
SRCS      += $(wildcard src/startup/*.c)
SRCS      += $(wildcard src/system/*.c)

# ASM sources
ASM_SOURCES =  "C:/data/traveo/TVII_Sample_Driver_Library_7.1.0/tviibe1m/src/startup_cm0plus.s"
#startup_cm0plus.s 


#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
 
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m0plus

# fpu
FPU = -mfpu=fpv4-sp-d16

# float-abi
FLOAT-ABI = -mfloat-abi=soft

# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

# macros for gcc
# AS defines
AS_DEFS = 

# C defines
#C_DEFS = ../../


# AS includes
AS_INCLUDES = 

# C includes

INCDIRS = ../../common/hdr
INCDIRS += ../../common/hdr/cmsis/include
INCDIRS += ../../common/src/drivers
INCDIRS += ../../common/src/drivers/sysclk
INCDIRS += ../../common/src/drivers/flash
INCDIRS += ../../common/src/drivers/syslib
INCDIRS += ../../common/src/drivers/mcwdt
INCDIRS += ../../tviibe1m/hdr/rev_d
INCDIRS += ../../tviibe1m/hdr/rev_d/ip
INCDIRS += ../../tviibe1m/src/system/rev_d
INCDIRS += ../../tviibe1m/hdr/rev_d/mcureg
INCDIRS += ../../tviibe1m/src/drivers/
INCDIRS += ../../common/src/drivers/syswdt
INCDIRS += ../../common/src/mw

INCLUDE   = $(addprefix -I,$(INCDIRS))

# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif

# My C flags:
CFLAGS += -Wno-unused-variable

# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"


#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = "c:/data/traveo/TVII_Sample_Driver_Library_7.1.0/tviibe1m/src/linker.ld"

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = 
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections

# default action: build all


all: $(TARGET)
blinkingled: main_cm0plus.o system_tviibe1m_cm0plus.o startup.o
    $(CC) $^ -o $@
    
    
main_cm0plus.o: main_cm0plus.c 
    $(CC) $(CFLAGS) main_cm0plus.c
    
system_tviibe1m_cm0plus.o: system_tviibe1m_cm0plus.c cy_project.h cy_device_headers.h 
    $(CC) $(CFLAGS) system_tviibe1m_cm0plus.c
    
    
startup.o: startup.c startup_customize.h
    $(CC) $(CFLAGS) startup.c
    
BIN_NAME  = $(addprefix $(BUILD_DIR), $(TARGET))

.PHONY: all
all: $(BIN_NAME).elf
all: $(BIN_NAME).bin
all: $(BIN_NAME).s19
all: $(BIN_NAME).hex
all: $(BIN_NAME).lst
all: print_size


%.bin: %.elf
    $(CP) -O binary -S 
lt; $@

%.s19: %.elf
    $(CP) -O srec -S 
lt; $@

%.hex: %.elf
    $(OBJCOPY) -O ihex -S 
lt; $@

%.lst: %.elf
    $(CP) -d 
lt; > $@

.PHONY: print_size
print_size: $(BIN_NAME).elf
    $(SIZE) 
lt;



#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))

$(BUILD_DIR)/%.o: %.c makefile | $(BUILD_DIR) 
    $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) 
lt; -o $@

$(BUILD_DIR)/%.o: %.s makefile | $(BUILD_DIR)
    $(AS) -c $(CFLAGS) 
lt; -o $@

$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) makefile
    $(CC) $(OBJECTS) $(LDFLAGS) -o $@
    $(SZ) $@

$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
    $(HEX) 
lt; $@
    
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
    $(BIN) 
lt; $@    
    
$(BUILD_DIR):
    mkdir $@        

#######################################
# clean up
#######################################
clean:
    -rm -fR $(BUILD_DIR)
  
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

# *** EOF ***

error:

c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-no
ne-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x18): undefined reference to `_exit'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\cygwin64\tmp\ccHNkyd5.o: in function `main':
main_cm0plus.c:(.text.main+0x2): undefined reference to `SystemInit'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: main_cm0plus.c:(.text.main+0xa): undefined reference to `Cy_SysEn
ableApplCore'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: main_cm0plus.c:(.text.main+0x14): undefined reference to `Cy_GPIO
_Pin_Init'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: main_cm0plus.c:(.text.main+0x1a): undefined reference to `Cy_SysT
ick_DelayInUs'
c:/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: main_cm0plus.c:(.text.main+0x28): undefined reference to `__cm4_v
ector_base_linker_symbol'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:173: main_cm0plus.o] Error 1

Does anyone knows how to solve this problem?
I am trying to generate a hex and elf from this makefile.
Also, I would appreciate any tips/corrections on my makefile. I am trying to blink a led but im very new to arm development with makefiles
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

路还长,别太狂 2025-02-15 21:31:55

请考虑以下问题:

all: blinkingled

blink: main_cm0plus.o system_tviibe1m_cm0plus.o startup.o
        $(CC) main_cm0plus.o system_tviibe1m_cm0plus.o startup.o -o blinkingled

在这里您有两个定义两个目标的规则:所有目标取决于先决条件blinkingledblink目标,取决于一堆对象文件。

当使blink目标调用时,它实际上会创建一个名为blinkingled的文件。这是错误的。 MAKE只知道您在Makefile中告诉它,它无法知道您对食谱会做什么撒谎。如果您使用名为blink的目标定义规则,则让您相信您提供的食谱将创建一个名为blink的目标。

您需要更改食谱,以便您告诉真相使目标与构建的文件匹配:

blinkingled: main_cm0plus.o system_tviibe1m_cm0plus.o startup.o
        $(CC) main_cm0plus.o system_tviibe1m_cm0plus.o startup.o -o blinkingled

现在一切都可以。

更好的是使用make's 自动变量食谱,因此您知道您正在创建目标的期望(另外,干燥是编程的重要原则):

blinkingled: main_cm0plus.o system_tviibe1m_cm0plus.o startup.o
        $(CC) $^ -o $@

Consider this:

all: blinkingled

blink: main_cm0plus.o system_tviibe1m_cm0plus.o startup.o
        $(CC) main_cm0plus.o system_tviibe1m_cm0plus.o startup.o -o blinkingled

Here you have two rules that define two targets: the all target depends on a prerequisite blinkingled and the blink target which depends on a bunch of object files.

When make invokes the blink target, it actually creates a file named blinkingled. This is wrong. Make only knows what you told it in the makefile, it has no way to know that you lied to it about what your recipe will do. If you define rule with a target named blink, then make believes you that the recipe you provided it will create a target named blink.

You need to change your recipe so that you are telling the truth to make and make the target match the file that is built:

blinkingled: main_cm0plus.o system_tviibe1m_cm0plus.o startup.o
        $(CC) main_cm0plus.o system_tviibe1m_cm0plus.o startup.o -o blinkingled

Now everything will work.

Even better is to use make's automatic variables in your recipe, so you KNOW that you're creating the targets make expects (plus, DRY is a great principle for programming):

blinkingled: main_cm0plus.o system_tviibe1m_cm0plus.o startup.o
        $(CC) $^ -o $@
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文