cancel
Showing results for 
Search instead for 
Did you mean: 

How to invoke Make with Makefile generated by STM32CubeMX

yakubin
Associate

I’ve generated a Makefile project in STM32CubeMX 6.12.0. This is the Makefile it generated:

##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [4.4.0-B60] date: [Fri Oct 25 00:09:08 CEST 2024]
##########################################################################################################################

# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
#	2017-02-10 - Several enhancements + project update mode
#   2015-07-22 - first version
# ------------------------------------------------

######################################
# target
######################################
TARGET = AdcDmaMakefile


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


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

######################################
# source
######################################
# C sources
C_SOURCES =  \
../../Core/Src/main.c \
../../Core/Src/stm32l4xx_it.c \
../../Core/Src/stm32l4xx_hal_msp.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
../../Core/Src/system_stm32l4xx.c \
../../Core/Src/sysmem.c \
../../Core/Src/syscalls.c  

# ASM sources
ASM_SOURCES =  \
startup_stm32l476xx.s

# ASM sources
ASMM_SOURCES = 


#######################################
# 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-m4

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

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

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

# macros for gcc
# AS defines
AS_DEFS = 

# C defines
C_DEFS =  \
-DUSE_HAL_DRIVER \
-DSTM32L476xx


# AS includes
AS_INCLUDES = 

# C includes
C_INCLUDES =  \
-I../../Core/Inc \
-I../../Drivers/STM32L4xx_HAL_Driver/Inc \
-I../../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy \
-I../../Drivers/CMSIS/Device/ST/STM32L4xx/Include \
-I../../Drivers/CMSIS/Include


# 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


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


#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32L476RGTx_FLASH.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: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin


#######################################
# 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)))
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASMM_SOURCES:.S=.o)))
vpath %.S $(sort $(dir $(ASMM_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)/%.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 ***

 Note the ../../ prefixes in C_SOURCES and C_INCLUDES. If I then run make in the project directory, it shows the error:

$ make
make: *** No rule to make target `build/main.o', needed by `build/AdcDmaMakefile.elf'.  Stop. 

This can be fixed by stripping the ../../ prefix from all those paths like so:

$ diff -u Makefile.old Makefile
--- Makefile.old 2024-10-25 00:09:25
+++ Makefile 2024-10-25 00:51:13
@@ -36,31 +36,31 @@
######################################
# C sources
C_SOURCES = \
-../../Core/Src/main.c \
-../../Core/Src/stm32l4xx_it.c \
-../../Core/Src/stm32l4xx_hal_msp.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
-../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
-../../Core/Src/system_stm32l4xx.c \
-../../Core/Src/sysmem.c \
-../../Core/Src/syscalls.c
+Core/Src/main.c \
+Core/Src/stm32l4xx_it.c \
+Core/Src/stm32l4xx_hal_msp.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
+Core/Src/system_stm32l4xx.c \
+Core/Src/sysmem.c \
+Core/Src/syscalls.c

# ASM sources
ASM_SOURCES = \
@@ -120,11 +120,11 @@

# C includes
C_INCLUDES = \
--I../../Core/Inc \
--I../../Drivers/STM32L4xx_HAL_Driver/Inc \
--I../../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy \
--I../../Drivers/CMSIS/Device/ST/STM32L4xx/Include \
--I../../Drivers/CMSIS/Include
+-ICore/Inc \
+-IDrivers/STM32L4xx_HAL_Driver/Inc \
+-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
+-IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
+-IDrivers/CMSIS/Include


# compile gcc flags
@@ -200,4 +200,4 @@
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

-# *** EOF ***
\ No newline at end of file
+# *** EOF ***

However, if I later regenerate the Makefile using STM32CubeMX, it will append another set of paths with the prefixes back:

$ diff -u Makefile.old Makefile
--- Makefile.old 2024-10-25 01:12:21
+++ Makefile 2024-10-25 01:12:29
@@ -1,5 +1,5 @@
##########################################################################################################################
-# File automatically-generated by tool: [projectgenerator] version: [4.4.0-B60] date: [Fri Oct 25 00:09:08 CEST 2024]
+# File automatically-generated by tool: [projectgenerator] version: [4.4.0-B60] date: [Fri Oct 25 01:12:29 CEST 2024]
##########################################################################################################################

# ------------------------------------------------
@@ -35,35 +35,60 @@
# source
######################################
# C sources
-C_SOURCES = \
-Core/Src/main.c \
-Core/Src/stm32l4xx_it.c \
-Core/Src/stm32l4xx_hal_msp.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
-Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
-Core/Src/system_stm32l4xx.c \
-Core/Src/sysmem.c \
-Core/Src/syscalls.c
+C_SOURCES = \
+Core/Src/main.c \
+Core/Src/stm32l4xx_it.c \
+Core/Src/stm32l4xx_hal_msp.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
+Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
+Core/Src/system_stm32l4xx.c \
+Core/Src/sysmem.c \
+Core/Src/syscalls.c \
+../../Core/Src/main.c \
+../../Core/Src/stm32l4xx_it.c \
+../../Core/Src/stm32l4xx_hal_msp.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
+../../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
+../../Core/Src/system_stm32l4xx.c \
+../../Core/Src/sysmem.c \
+../../Core/Src/syscalls.c

# ASM sources
-ASM_SOURCES = \
+ASM_SOURCES = \
startup_stm32l476xx.s

# ASM sources
@@ -110,8 +135,8 @@
AS_DEFS =

# C defines
-C_DEFS = \
--DUSE_HAL_DRIVER \
+C_DEFS = \
+-DUSE_HAL_DRIVER \
-DSTM32L476xx


@@ -119,12 +144,17 @@
AS_INCLUDES =

# C includes
-C_INCLUDES = \
--ICore/Inc \
--IDrivers/STM32L4xx_HAL_Driver/Inc \
--IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
--IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
--IDrivers/CMSIS/Include
+C_INCLUDES = \
+-ICore/Inc \
+-IDrivers/STM32L4xx_HAL_Driver/Inc \
+-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
+-IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
+-IDrivers/CMSIS/Include \
+-I../../Core/Inc \
+-I../../Drivers/STM32L4xx_HAL_Driver/Inc \
+-I../../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy \
+-I../../Drivers/CMSIS/Device/ST/STM32L4xx/Include \
+-I../../Drivers/CMSIS/Include


# compile gcc flags
@@ -200,4 +230,4 @@
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

-# *** EOF ***
+# *** EOF *** 

At that point, with the file paths fixed, I get to this error:

$ make
arm-none-eabi-gcc build/main.o build/stm32l4xx_it.o build/stm32l4xx_hal_msp.o build/stm32l4xx_hal_adc.o build/stm32l4xx_hal_adc_ex.o build/stm32l4xx_hal.o build/stm32l4xx_hal_rcc.o build/stm32l4xx_hal_rcc_ex.o build/stm32l4xx_hal_flash.o build/stm32l4xx_hal_flash_ex.o build/stm32l4xx_hal_flash_ramfunc.o build/stm32l4xx_hal_gpio.o build/stm32l4xx_hal_i2c.o build/stm32l4xx_hal_i2c_ex.o build/stm32l4xx_hal_dma.o build/stm32l4xx_hal_dma_ex.o build/stm32l4xx_hal_pwr.o build/stm32l4xx_hal_pwr_ex.o build/stm32l4xx_hal_cortex.o build/stm32l4xx_hal_exti.o build/stm32l4xx_hal_tim.o build/stm32l4xx_hal_tim_ex.o build/system_stm32l4xx.o build/sysmem.o build/syscalls.o build/startup_stm32l476xx.o -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nano.specs -TSTM32L476RGTx_FLASH.ld -lc -lm -lnosys -Wl,-Map=build/AdcDmaMakefile.map,--cref -Wl,--gc-sections -o build/AdcDmaMakefile.elf
/opt/local/lib/gcc/arm-none-eabi/14.2.0/../../../../arm-none-eabi/bin/ld: cannot find -lc_nano: No such file or directory
/opt/local/lib/gcc/arm-none-eabi/14.2.0/../../../../arm-none-eabi/bin/ld: cannot find -lc_nano: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [build/AdcDmaMakefile.elf] Error 1 

So it seems I need to install some library, but I’not sure where to get it from. I’m on Mac, if that helps.

So 2 questions:

  1. Am I running the Make command not the right way, which prevents originals paths from working? How should it be invoked? Or maybe should the Makefile be generated differently?
  2. What library should I install on Mac and where should I get it from to get rid of the linking error?

Thanks,
Jakub

2 REPLIES 2
Pavel A.
Evangelist III

Try to change current directory. Create a sub-dir.

What library should I install on Mac 

It should be already installed with CubeIDE.

The exact name of the nano library is defined in the .spec file - which must be provided in gcc or g++ options.

 


@Pavel A. wrote:

Try to change current directory. Create a sub-dir.

I’ve tried that. However, note that the Makefile contains rules like the following:

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 

Which requires the Makefile to be in the current directory. So invoking it from another directory doesn’t work.

I’ve also found examples of Makefiles generated by CubeMX, which don’t contain the ../../ prefixes in paths in C_SOURCES and C_INCLUDES. See e.g. the Makefile in https://community.st.com/t5/stm32cubemx-mcus/cubemx-generated-project-compiling-main-cpp-using-makefile/td-p/182895. So I’m wondering whether there is an option in CubeMX which controls that.