2026-04-27 6:48 AM - last edited on 2026-04-28 2:10 AM by Andrew Neil
Hi
I am using latest CubeMx Ver 16.7.0 and CubeIde Ver 2.1.1
while trying to compile a USB CDC code this error shows once i linked the code :
"
C:/Users/../../Hardware - General/../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'
C:/ST/STM32CubeIDE_2.0.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.14.3.rel1.win32_1.0.100.202602081740/tools/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld.exe: (MX_USB_CDC_Init): Unknown destination type (ARM/Thumb) in ./Core/Src/stm32u0xx_hal_msp.o
C:/Users/../../Hardware - General/../Electronics/../Software/USB_CDC_U0/USB_CDC_U0/Debug/../Core/Src/stm32u0xx_hal_msp.c:102:(.text.HAL_PCD_MspInit+0x4c): dangerous relocation: unsupported relocation
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:65: USB_CDC_U0.elf] Error 1
"
the called the function "MX_USB_CDC_Init" exist in the USB/Class/CDC dir, and the H file hold the function prototype and referenced from the "stm32u0xx_hal_msp.c" file
I have attached the project
Please help
Solved! Go to Solution.
2026-04-28 6:40 AM
Probably time to mark this thread as solved, and start a new thread for the other error?
Give a link here to the new thread;
Include a link in the new thread back to this one, for reference, if you think it helps.
2026-04-27 6:58 AM - edited 2026-04-27 7:07 AM
I think this is the key:
@UVC100 wrote:Core/Src/stm32u0xx_hal_msp.c:102:(.text.HAL_PCD_MspInit+0x4c): dangerous relocation: unsupported relocation
See recent threads:
Seems to relate to a recent Assembler change:
Proposed Solution:
2026-04-27 7:38 AM
Hi
I have read all the similar solution before and try all of them:
1. update the CubeIde .
2. Update CubeMx.
3. There was a suggestion to update the GCC tools - I have the latest GCC tools (according to the tool manager in the CubeIDE)
4. There was a suggestion to delete some system files and re-generate them with the CubeMx - not working
Sorry, not working for me
2026-04-27 7:51 AM
@UVC100 wrote:3. There was a suggestion to update the GCC tools
Specifically, GNU Tools for STM32 (13.3.rel1) - is that the version you have ?
@Mahmoud Ben Romdhane @Ghofrane GSOURI
2026-04-27 10:13 PM
Hi Andrew ,
Thank you for the fast replay,
I have 14.3rel1 gnu tools installed in my CUBEIDE - as I understand the tool version is newer and suppose to include all the changes and updates done in 13.3rel1?
UVC100
2026-04-28 2:07 AM - edited 2026-04-28 2:07 AM
Looking back at that thread where 13.3.rel1 was accepted as the solution, the original problem was reported with GNU tools for STM32 14.3.1.
So it's 14.3.1 which introduces the problem - therefore you need to downgrade to 13.3.1 to fix it.
2026-04-28 5:44 AM
Hi Andrew ,
I have installed version 13.3.rel1, clean the files and re compile the code :
I have a different error from linker "undefined reference to the same function" although the function referenced in the files.
"
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)
UVC100
2026-04-28 6:40 AM
Probably time to mark this thread as solved, and start a new thread for the other error?
Give a link here to the new thread;
Include a link in the new thread back to this one, for reference, if you think it helps.