multiple definition of `SystemCoreClock' (system_stm32g4xx.c included twice)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-10 07:48 AM
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
- Labels:
-
RCC
-
STM32CubeIDE
-
STM32CubeMX
-
STM32G4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-10 07:59 AM
Update:
For the nonce, my workaround is to simply exclude Core/Src/system_stm32g4xx.c from the build (so it uses the file from CMSIS instead). It compiled and linked without error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-12 03:18 AM
Hello @Robert Poor​ ,
First let me thank you for having reported :smiling_face_with_smiling_eyes:
In fact I wasn't able to reproduce any building issue from my side when starting a project based on STM32G431RBTx MCU and using the latest version of STM32CubeMX / STM32CubeIDE: the build has finished without any errors.
Could you please add more details about how did you proceed or attach your .ioc file to be able to further investigate from my side.
Your feedback will be very helpful to track the root cause of the issue.
Khouloud.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-09 01:32 PM
I have same kind of problem: multiple defined symbols:
SystemCoreClock
SystemD2Clock
D1CorePrescTable
SystemInit
SystemCoreClockUpdate
22:17:38 **** Incremental Build of configuration Debug for project SmartCam1 ****
make -j8 all
arm-none-eabi-g++ -o "SmartCam1.elf" @"objects.list" -mcpu=cortex-m7 -T"D:\Dropbox (Mechamania)\Exoleap\sub_projects\SmartCam\software\SmartCam1\STM32H743VITX_FLASH.ld" --specs=nosys.specs -Wl,-Map="SmartCam1.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group
c:\st\stm32cubeide_1.10.1\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/STM32H7xx/Source/Templates/system_stm32h7xx.o:D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c:148: multiple definition of `SystemCoreClock'; ./Core/Src/system_stm32h7xx.o:D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Core/Src/system_stm32h7xx.c:148: first defined here
c:\st\stm32cubeide_1.10.1\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/STM32H7xx/Source/Templates/system_stm32h7xx.o:D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c:149: multiple definition of `SystemD2Clock'; ./Core/Src/system_stm32h7xx.o:D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Core/Src/system_stm32h7xx.c:149: first defined here
c:\st\stm32cubeide_1.10.1\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/STM32H7xx/Source/Templates/system_stm32h7xx.o:D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c:150: multiple definition of `D1CorePrescTable'; ./Core/Src/system_stm32h7xx.o:D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Core/Src/system_stm32h7xx.c:150: first defined here
c:\st\stm32cubeide_1.10.1\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/STM32H7xx/Source/Templates/system_stm32h7xx.o: in function `SystemInit':
D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c:176: multiple definition of `SystemInit'; ./Core/Src/system_stm32h7xx.o:D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Core/Src/system_stm32h7xx.c:176: first defined here
c:\st\stm32cubeide_1.10.1\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/STM32H7xx/Source/Templates/system_stm32h7xx.o: in function `SystemCoreClockUpdate':
D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c:341: multiple definition of `SystemCoreClockUpdate'; ./Core/Src/system_stm32h7xx.o:D:/Dropbox (Mechamania)/Exoleap/sub_projects/SmartCam/software/SmartCam1/Debug/../Core/Src/system_stm32h7xx.c:341: first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:84: SmartCam1.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.
22:17:39 Build Failed. 8 errors, 0 warnings. (took 1s.357ms)
I zipped and attacjed my project folder.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-09 02:00 PM
@CJans.1​ Files in Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates should not be included in build.
Is your makefile generated by CubeMX or CubeIDE? If not, please fix the makefile or CubeIDE project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-09 02:09 PM
Regarding the OP, note that I used CubeIDE, and I didn't specifically ask for two copies of system_stm32g4xx.c, but that's what CubeIDE generated. I had to manually exlude of of the two from the project to get it to compile.
This seems like a bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-09 02:43 PM
@Robert Poor​ Yes, I recall the bug in CubeMX or CubeIDE that copied templates of some C files from the repository when regenerating a project. But IIRC it has been fixed long ago.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-09 03:52 PM
How should I remove it? Just delete it from the project browser? I do not want to delete anything that I should not delete.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-09 05:44 PM
- Exclude all these duplicate files in /Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/ from build.
- If this helps, you can delete the directory /Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/ if it is copied into your project directory, then refresh the project in eclipse.
- Consider instead of copying the ST library files into your project directory to create references to the library location (share the ST library among many projects).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-09 06:37 PM
@Pavel A.​
"But IIRC it has been fixed long ago."
That may be true, but note that I reported this problem July 10, 2022 (not that long ago). Here's the version number and build date:
STM32CubeIDE
Version: 1.10.0
Build: 12671_20220627_1643 (UTC)