Skip to main content
DBrau.2
Associate III
March 29, 2022
Solved

Multiple definition after update CubeIDE

  • March 29, 2022
  • 3 replies
  • 5939 views

Hi. Can you say me what mean that type of error.

The code is surely correct because I've been working on it. The errors showed up after updating CubeIDE to a new version and generating files from .ioc file in IDE.

c:\st\stm32cubeide_1.7.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: ./Core/Src/communication/sms.o:C:/master_g474ve/Debug/../Core/Inc/config.h:54: multiple definition of `config'; ./Core/Src/battery_charger.o:C:/master_g474ve/Debug/../Core/Inc/config.h:54: first defined here

3 replies

TDK
Super User
March 29, 2022

Is config.h a CubeMX generated file? Certainly neither sms.c nor battery_charger.c is.

Probably you have the "config" variable/function defined in config.h, which is being included in two compilation units, which leads to duplicate definitions.

Move your definitions into source files and keep only the declaration in the header.

> The code is surely correct because I've been working on it.

Not sure that logic tracks.

"If you feel a post has answered your question, please click ""Accept as Solution""."
TDK
TDKBest answer
Super User
March 29, 2022
"If you feel a post has answered your question, please click ""Accept as Solution""."
DBrau.2
DBrau.2Author
Associate III
March 30, 2022

Yes. It's answer to my question

Explorer
July 18, 2023

Please go through https://gcc.gnu.org/gcc-10/porting_to.html

In STM32CubeIDE, Goto Project Properties-> --> C/C++ Build -->Settings--> MCU GCC Compiler--> Miscellaneous--> other flags --> Add -fcommon    Apply and Close.

Hope this will help.

ABerg.8
Associate II
September 27, 2024

Hallo Mitarbeiter II, das hat bei mir geholfen, es kam die Fehlermeldung, einer doppelten Definition in einer  .o Datei.

-fcommon eingetragen, und keine Fehlermeldung mehr, GENIAL. Was bewirkt dieser Eintrag ? Danke nochmal von ganzem Herzen. Liebe Grüße