jbaumann / pio_and_stm32cubeide

Use PlatformIO with Projects generated by STM32CubeIDE
Apache License 2.0
23 stars 9 forks source link

error of redefinition #8

Closed Xinyu-Sheng closed 1 year ago

Xinyu-Sheng commented 1 year ago

I am a beginner with PlatformIO. Following your script, I encountered an error of redefinition during linking. Is it due to my personal reason? What are the possible solutions?

.pio/build/black_f407zg/src/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o: In function `HAL_DeInit':
stm32f4xx_hal.c:(.text.HAL_DeInit+0x0): multiple definition of `HAL_DeInit'
.pio/build/black_f407zg/FrameworkHALDriver/Src/stm32f4xx_hal.o:stm32f4xx_hal.c:(.text.HAL_DeInit+0x0): first defined here
.pio/build/black_f407zg/src/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o: In function `HAL_Init':
stm32f4xx_hal.c:(.text.HAL_Init+0x0): multiple definition of `HAL_Init'
jbaumann commented 1 year ago

This looks as if somehow the framework files are used twice, which is strange. Which version of the STM32CubeIDE and PlatformIO are you using? Does your code compile in the STM32CubeIDE? And could you maybe attach the part of your project that produces this problem (please strip it down to the absolute minimum that produces the problem)?

Xinyu-Sheng commented 1 year ago

I generated the entire project using CubeMX, and added platformio.ini and setup_cubemx_env_auto.py in the project folder. After compilation, the project structure is as follows: image I believe that during the build process, similar target files were generated in the pio/build folder for FrameworkHALDriver and src, one from the driver generated by CubeMX and the other from PlatformIO. I am using Win11 environment with PIO version 6.1.6 and CubeMX version 6.7.0.

Xinyu-Sheng commented 1 year ago

I think I found the issue. If I want to use the libraries from cubemx, I should use automatic_cubemx instead of automatic_pio!

jbaumann commented 1 year ago

Excellent. Can I close the issue then?

Xinyu-Sheng commented 1 year ago

Yes, and thank you for your work!