cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 gnu tools version 13.3.rel1 undefined reference linker error

UVC100
Associate

I have installed version  13.3.rel1, clean the files and re compile the code :

I have a linker error "undefined reference" to a function although the function referenced in the files and declared in the H file who was included. 

 " 

C:/ST/STM32CubeIDE_2.0.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.100.202509120712/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/stm32u0xx_hal_msp.o: in function `HAL_PCD_MspInit':

C:/Users/../Electronics/../Software/USB_CDC_U0/USB_CDC_U0/Debug/../Core/Src/stm32u0xx_hal_msp.c:102:(.text.HAL_PCD_MspInit+0x4c): undefined reference to `MX_USB_CDC_Init'

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:65: USB_CDC_U0.elf] Error 1

"make -j12 all" terminated with exit code 2. Build might be incomplete.

15:33:51 Build Failed. 2 errors, 0 warnings. (took 13s.995ms)

I have tried the following:

1. I have tried changing the file order in "path and symbols" clean and recompile - no success   

2. I have tried changing the function name - - no success

3. I have deleted the object files in the debug section clean the code and re-compile - no success.

currently I am using version 13.3.rel1 of STM32 GNU and CubeIDE 2.1.1 tools downgraded from version 14.3.rel1 due to other errors encountered while compiling the code - see the link below:

https://community.st.com/t5/stm32cubeide-mcus/unknown-destination-type-arm-thumb-link-error-in-cubeide-v2-1-1/m-p/895174#M41819

I have attached the code 

Please help 

UVC100  

 

3 REPLIES 3
Andrew Neil
Super User

Are you sure that the source file containing the definition (not just the prototype) of MX_USB_CDC_Init is actually included in the build?

Does the CubeIDE 'Go To Definition' find it?

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hi Andrew,

In the last test I done , I change the name of function, thought the name is to long , it has no effect the on the result - same linker error.

Please see below the text from the updated function name :

"C:/ST/STM32CubeIDE_2.0.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.100.202509120712/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/stm32u0xx_hal_msp.o: in function `HAL_PCD_MspInit':

C:/Users/../Hardware - General/../../Software/USB_CDC_U0/USB_CDC_U0/4c): undefiDebug/../Core/Src/stm32u0xx_hal_msp.c:102:(.text.HAL_PCD_MspInit+0xned reference to `MX_USB_INIT'

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:65: USB_CDC_U0.elf] Error 1

"make -j12 all" terminated with exit code 2. Build might be incomplete."

The function current name is :MX_USB_INIT()

the function located in the USB_CDC_IF.c file (see attached code)

the function Exported in the in the USB_CDC_IF.h

call to the function done in the STM32U0xx_hal_msp.c within the function HAL_PCD_MspInit()

USB_CDC_IF.h was included in the STM32U0xx_hal_msp.c file

Thank you


@UVC100 wrote:

the function located in the USB_CDC_IF.c file (see attached code)


And are you sure that file is actually being built ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.