cancel
Showing results for 
Search instead for 
Did you mean: 

multiple definition of `SystemCoreClock' (system_stm32g4xx.c included twice)

Robert Poor
Associate III

I thought this was a manifestation of the previously reported bug Multiple definition error after STM32CubeIDE 1.9.0 update, but adding -fcommon to my compiler flags didn't fix it.

The error message is:

  • multiple definition of `SystemCoreClock'
  • multiple definition of `AHBPrescTable'

The root problem appears that two copies of system_stm32g4xx.c are being included in the build:

  • Core/Src/system_stm32g4xx.c
  • Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c

Here's an example of the full error message:

c:\st\stm32cubeide_1.9.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: ./Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.o:C:/Users/r/Projects/mulib-examples/test_stdbsp/nucleo_g431rb/Debug/../Drivers/CMSIS/Device/ST/STM32G4xx/Source/Templates/system_stm32g4xx.c:152: multiple definition of `SystemCoreClock'; ./Core/Src/system_stm32g4xx.o:C:/Users/r/Projects/mulib-examples/test_stdbsp/nucleo_g431rb/Debug/../Core/Src/system_stm32g4xx.c:152: first defined here

The questions:

Is this a known issue, and if so, what's a suitable workaround or proper fix?

A newcomer, what's the best way to capture the relevant environmental info in STM32CubeIDE?

Environment:

STM32CubeIDE

Version: 1.10.0

Build: 12671_20220627_1643 (UTC)

C/C++ Development Platform

Version: 10.6.2.202205170638

Build id: 20220517-0638

Eclipse Platform

Version: 4.23.0.v20220308-0722

Build id: I20220308-0310

STM32CubeIDE - C/C++ Embedded Development Tools for MCU

Version: 2.0.100.202110131350

Windows 11 Pro v 22H2

10 REPLIES 10

Thanks! Had the same issue, deleting manually works fine, but when regenerating code I need to delete it again :downcast_face_with_sweat: .