2022-03-29 09:48 PM
arm-none-eabi-gcc -o "Uart_Ring_Buffer.elf" @"objects.list" -mcpu=cortex-m4 -T"C:\Users\User\STM32CubeIDE\workspace_1.8.0\Uart_Ring_Buffer\STM32F429ZITX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Uart_Ring_Buffer.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
c:\st\stm32cubeide_1.8.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/main.o:C:/Users/User/STM32CubeIDE/workspace_1.8.0/Uart_Ring_Buffer/Debug/../Core/Src/main.c:50: multiple definition of `huart2'; ./Core/Src/UartRingbuffer.o:C:/Users/User/STM32CubeIDE/workspace_1.8.0/Uart_Ring_Buffer/Debug/../Core/Src/UartRingbuffer.c:15: first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:64: Uart_Ring_Buffer.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.
Solved! Go to Solution.
2022-03-29 10:14 PM
Error says you defined a variable in two files. Need to not do that.
Decide where you want it, and use extern elsewhere.
2022-03-29 10:14 PM
Error says you defined a variable in two files. Need to not do that.
Decide where you want it, and use extern elsewhere.
2022-03-30 06:27 AM - edited 2023-11-20 08:53 AM
After searching huart2 in my code as shown below , I use extern as you mention
Do you see any error (multiple definition of `huart2';) ?
2022-03-30 06:39 AM
Is it in an include file?
2022-03-30 07:31 AM
> multiple definition of `huart2';
> ./Core/Src/UartRingbuffer.o:C:/Users/User/STM32CubeIDE/workspace_1.8.0/Uart_Ring_Buffer/Debug/../Core/Src/UartRingbuffer.c:15: first defined here
The error indicates that you've defined huart2 in UartRingbuffer.c on line 15. It shouldn't be defined there. Use extern. Would be easier to spot the error if you attached the relevant files.
2022-03-30 08:31 AM
Thanks , Tesla & TDK
you are correct it was in UartRingBuffer.c