STM32CubeIDE报错 undefined reference to

本文介绍了在遇到C/C++工程无法识别头文件时的常见问题及解决方案,包括检查头文件后缀名是否使用大写,以及如何在工程属性中正确配置源文件路径,确保每次新增源文件文件夹时都能被正确识别。

解决办法:

  1. 检查头文件的后缀名是否用了大写,如下图
    在这里插入图片描述
    2. 工程没有配置源文件路径
    右击工程名->Properties->C/C++ General->Source Location处添加源文件路径(每次新增源文件文件夹需要在此处添加)
    在这里插入图片描述
在使用STM32CubeIDE进行编译时,出现以下错误: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/gpio.c:51:(.text.MX_GPIO_Init+0x72): undefined reference to `HAL_GPIO_WritePin' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/gpio.c:58:(.text.MX_GPIO_Init+0x98): undefined reference to `HAL_GPIO_Init' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/main.o: in function `main': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:85:(.text.main+0x4): undefined reference to `HAL_Init' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:115:(.text.main+0x20): undefined reference to `HAL_UART_Receive_IT' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:126:(.text.main+0x3e): undefined reference to `HAL_UART_Transmit_IT' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/main.o: in function `SystemClock_Config': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:162:(.text.SystemClock_Config+0x66): undefined reference to `HAL_RCC_OscConfig' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:174:(.text.SystemClock_Config+0x92): undefined reference to `HAL_RCC_ClockConfig' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/main.c:180:(.text.SystemClock_Config+0xae): undefined reference to `HAL_RCCEx_PeriphCLKConfig' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/stm32f0xx_it.o: in function `SysTick_Handler': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/stm32f0xx_it.c:130:(.text.SysTick_Handler+0x4): undefined reference to `HAL_IncTick' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/stm32f0xx_it.o: in function `USART1_IRQHandler': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/stm32f0xx_it.c:151:(.text.USART1_IRQHandler+0x8): undefined reference to `HAL_UART_IRQHandler' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/stm32f0xx_it.o: in function `USART2_IRQHandler': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/stm32f0xx_it.c:165:(.text.USART2_IRQHandler+0x8): undefined reference to `HAL_UART_IRQHandler' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/usart.o: in function `MX_USART1_UART_Init': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/usart.c:45:(.text.MX_USART1_UART_Init+0x46): undefined reference to `HAL_UART_Init' D:/ST/STM32CubeIDE_1.18.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Src/usart.o: in function `MX_USART2_UART_Init': D:/ST/STM32CubeIDE/workspace_1.18.1/F030/usart2comm/Debug/../Src/usart.c:66:(.text.MX_USART2_UART_Init+0x46): undefined reference to `HAL_UART_Init' collect2.exe: error: ld returned 1 exit status make: *** [makefile:63: usart2comm.elf] Error 1 "make -j12 all" terminated with exit code 2. Build might be incomplete. 15:08:20 Build Failed. 14 errors, 0 warnings. (took 5s.624ms)
最新发布
07-10
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

零涂

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值