2023-01-23 07:18 PM
I'm new to STM32 and my C skills are very rusty
I'm trying to create a simple program to demo the usage of an Adafruit SSD1306 SPI OLED board
In my main.c I need to #include "ssd1306.h" from this driver because I need some of the definitions.
The problem is that I'm receiving a bunch of multiple definition errors. For example:
multiple definition of `HAL_EXTI_ClearConfigLine'; ./Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_exti 3.o:/Users/chrisk/Documents/STM32CubeIDE/workspace_1.11.0/STM32_AdafruitSSD1306_128x32_Example/Debug/../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_exti 3.c:318: first defined here stm32f0xx_hal_exti.c /STM32_AdafruitSSD1306_128x32_Example/Drivers/STM32F0xx_HAL_Driver/Src line 318 C/C++ Problem
multiple definition of `HAL_EXTI_ClearPending'; ./Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_exti 3.o:/Users/chrisk/Documents/STM32CubeIDE/workspace_1.11.0/STM32_AdafruitSSD1306_128x32_Example/Debug/../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_exti 3.c:497: first defined here stm32f0xx_hal_exti.c /STM32_AdafruitSSD1306_128x32_Example/Drivers/STM32F0xx_HAL_Driver/Src line 497 C/C++ Problem
multiple definition of `HAL_EXTI_GenerateSWI'; ./Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_exti 3.o:/Users/chrisk/Documents/STM32CubeIDE/workspace_1.11.0/STM32_AdafruitSSD1306_128x32_Example/Debug/../Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_exti 3.c:518: first defined here stm32f0xx_hal_exti.c /STM32_AdafruitSSD1306_128x32_Example/Drivers/STM32F0xx_HAL_Driver/Src line 518 C/C++ Problem
If I remove the #include "ssd1306.h" line that problem goes away, but I need the definitions so this isn't a viable solution.
My best guess is that ssd1306.h is including a resource around line 18 that is included someplace else and therefore causes the multiple definition error. More likely I'm totally missing something important.
Any ideas or suggestions?
Thanks!
Chris
2023-01-24 12:19 PM
does your ssd1306.h file have the code wrap something like this:
#ifndef _SSD1306_H_
#define _SSD1306_H_
(...)
#endif
?
2023-01-25 12:03 PM
I solved this, but I don't understand the root cause.
I found copies of most or all of the STM32F0xx_HAL_Driver .c files that were causing the issue. These copies were identical except for a " 3.c" extension. I have no idea how these were created, but when I deleted them the issue above went away.