cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX bug report: Error in generating Makefile

Ludwig Horsthemke
Associate
Posted on November 02, 2017 at 16:28

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

https://pastebin.com/Qs7SmrZR

. This leads to compile time errors like

build/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
13 REPLIES 13
Imen.D
ST Employee
Posted on November 02, 2017 at 16:34

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Kacper Czochara
Associate
Posted on November 06, 2017 at 16:20

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6uA&d=%2Fa%2F0X0000000bxi%2F3WgrV8GZr3BI7nFdEqGqaOqDRwVyuG4sFPkiHo7dC6U&asPdf=false
Posted on November 07, 2017 at 01:10

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.

emil
Associate II
Posted on December 15, 2017 at 16:08

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

Jeanne Joly
Senior III
Posted on February 12, 2018 at 15:16

hello

luddi

,

kacperczochara

and

Laurentiu.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

Cameron Moore
Associate II
Posted on April 23, 2018 at 14:58

Hi,

I am having the same issues. I cannot find any duplicates in the makefile. Is there another way I can fix this error?

Posted on April 24, 2018 at 07:10

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

Posted on April 25, 2018 at 05:28

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6uy&d=%2Fa%2F0X0000000bxx%2FciJg.3YfvVIZejMyG9muDsOdkFc_XQYnK35iWZob_VM&asPdf=false
Posted on April 25, 2018 at 07:36

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 119

I don't have your copies of these files, but found template versions which verify these duplicate functions.

https://community.st.com/external-link.jspa?url=https%3A%2F%2Fgithub.com%2Fopenmv%2Fopenmv%2Fblob%2Fmaster%2Fsrc%2Fsthal%2Ff7%2Fsrc%2Fstm32f7xx_hal_timebase_rtc_wakeup_template.c%23L120

https://community.st.com/external-link.jspa?url=https%3A%2F%2Fgithub.com%2Fopenmv%2Fopenmv%2Fblob%2Fmaster%2Fsrc%2Fsthal%2Ff7%2Fsrc%2Fstm32f7xx_hal_timebase_rtc_alarm_template.c%23L113

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.