CubeMX bug report: Error in generating Makefile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-02 8:28 AM
Hello,
after upgrading CubeMX to version 4.0 on linux I noticed a bug in the generation of ./Makefile. The '# paths' section includes *.c files next to the directories and the '# sources' section includes some files twice. You can find an example makefile at
. This leads to compile time errors likebuild/stm32f1xx_hal_timebase_TIM.o: In function `HAL_InitTick':
~/workspace/test107/Src/stm32f1xx_hal_timebase_TIM.c:79: multiple definition of `HAL_InitTick'
�?�?�?�?�?
Please have a look if you can recreate this.
Kind regards,
Ludwig
#bug-report- Labels:
-
Bug-report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-02 8:34 AM
Hello
luddi
,Thanks for reported this issue.
It is raised internally to CubeMx team for investigation and we will come back to you as soon as possible.
Best Regards
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-06 7:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-11-06 5:10 PM
As an update, I have managed to get it running after looking at it again by removing all the duplicates from makefile. I would love to see it fixed anyways.
--
Another update. I have just generated project including RTC for f103c8t6. The makefile was missing references to _hal_rtc.c and _hal_rtc_ex.c. Instead there was referenced file that wasn't present in Drivers folder, can't provide the name of it right now. There were also those duplicates as reported earlier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-12-15 7:08 AM
I have encountered the same problem.
This is caused by multiple entries in the C_SOURCES macro.
In the example bellow usbd_desc.c is listed twice:
C_SOURCES = \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c \
Src/stm32f4xx_it.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
Src/usb_device.c \
Src/usbd_conf.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
Src/usbd_desc.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \
Src/stm32f4xx_it.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c \
Src/usb_device.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
Src/usbd_desc.c \
Src/system_stm32f4xx.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
Src/usbd_conf.c \
Src/usbd_cdc_if.c
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-02-12 6:16 AM
hello
luddi
,kacperczochara
andLaurentiu.Emil
,I confirm theissue of duplicated source files when CubeMX generates the code with makefile.
As you say, the workaround is to suppress every duplicated source files and it compiles and links successfully after.
Sorry for the inconvenience it may cause.
Our development teams are working on that point, I will keep you inform as soon as the correction is available in a CubeMX release.
BR. Jeanne
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-23 5:58 AM
Hi,
I am having the same issues. I cannot find any duplicates in the makefile. Is there another way I can fix this error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-24 12:10 AM
There are other ways to generate a 'multiple definition' error besides duplicating source files in the makefile. For example, missing header guards could cause this problem, along with other possible root causes. If you give us more information, we'll have a better chance at helping you solve this issue.
- Can you attach the makefile you are using? Is this the makefile autogenerated by CubeMX?
- Can you post the build command, along with the error message. For example here's my build output after running 'make' to trigger a 'multiple definition' error.
/usr/bin/arm-none-eabi-gcc build/stm32l4xx_hal_flash.o build/system_stm32l4xx.o build/stm32l4xx_it.o build/stm32l4xx_hal_dma_ex.o build/stm32l4xx_hal_adc_ex.o build/stm32l4xx_hal_i2c.o build/stm32l4xx_hal_gpio.o build/main.o build/main.o build/stm32l4xx_hal_pwr_ex.o build/stm32l4xx_hal_msp.o build/stm32l4xx_hal_adc.o build/stm32l4xx_hal_rcc.o build/stm32l4xx_hal_tim.o build/stm32l4xx_hal_tim_ex.o build/stm32l4xx_hal_cortex.o build/stm32l4xx_hal_flash_ex.o build/stm32l4xx_hal.o build/stm32l4xx_hal_i2c_ex.o build/stm32l4xx_hal_flash_ramfunc.o build/stm32l4xx_hal_dma.o build/stm32l4xx_hal_pwr.o build/stm32l4xx_hal_rcc_ex.o build/startup_stm32l432xx.o -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nano.specs -TSTM32L432KCUx_FLASH.ld -lc -lm -lnosys -Wl,-Map=build/bare_chip.map,--cref -Wl,--gc-sections -o build/bare_chip.elf
build/main.o: In function `_Error_Handler':/home/miles/projects/hsdd/autogen/dummy/bare_chip/Src/main.c:349: multiple definition of `_Error_Handler'build/main.o:/home/miles/projects/hsdd/autogen/dummy/bare_chip/Src/main.c:349: first defined here- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-24 10:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-25 12:36 AM
For the first error, it looks like the HAL_InitTick function is defined in the following two files:
system/src/stm32f7xx/stm32f7xx_hal_timebase_rtc_alarm.c at line 112
system/src/stm32f7xx/stm32f7xx_hal_timebase_rtc_wakeup.c at line 119I don't have your copies of these files, but found template versions which verify these duplicate functions.
I don't think there's a way to keep both functions without marking one or both of them as static, although you shouldn't have to modify the HAL library code. I think the best path forward is to remove one or both of these files from your makefile, but this is also tough, since I don't know which makefile includes them. Best guess is that they're picked up by '-include system/src/stm32f7xx/subdir.mk'.
There's a cubeMX autogeneration option in the advanced project settings to minimize included library files to only what's needed by your application, rather than including and building all of them. Enabling this may eliminate these conflicting files. Your autogenerated makefiles are different than what I get running standalone cubeMX, so I'm not sure if this is an option in your environment.
