• 在 Keil MDK 中,编译项目时,报如下错误
*** Using Compiler 'V5.06 update 1 (build 61)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'Target 1'
assembling startup_stm32f103xe.s...
compiling stm32f1xx_hal_rcc_ex.c...
compiling stm32f1xx_hal_gpio_ex.c...
compiling stm32f1xx_hal_uart.c...
compiling stm32f1xx_hal_dma.c...
compiling sys.c...
compiling usart.c...
compiling stm32f1xx_hal_usart.c...
compiling system_stm32f1xx.c...
compiling main.c...
compiling delay.c...
compiling stm32f1xx_it.c...
compiling stm32f1xx_hal_rcc.c...
compiling stm32f1xx_hal_cortex.c...
compiling stm32f1xx_hal_gpio.c...
compiling stm32f1xx_hal.c...
compiling gtim.c...
compiling stm32f1xx_hal_tim_ex.c...
compiling stm32f1xx_hal_tim.c...
linking...
..\..\hal_led_breathe.axf: Error: L6218E: Undefined symbol led_init (referred from main.o).
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 1 error messages.
"..\..\hal_led_breathe.axf" - 1 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:08
# 关键错误

..\..\hal_led_breathe.axf: Error: L6218E: Undefined symbol led_init (referred from main.o).
问题原因
  • 主要问题如上,这个问题表示链接器找不到 led_init 函数的实现,导致编译失败,可能有如下原因
  1. 未实现 led_init 函数:可能在头文件(例如,led.h)中声明了该函数,但没有在 .c 文件中实现

  2. 未将 led.c 文件添加到 Keil MDK 工程:led_init 已经正确实现实现,但该文件未被包含到 Keil MDK 工程中

  3. 函数名拼写错误:实现或调用函数时的拼写错误

处理策略
  1. 确保实现 led_init 函数

  2. 确保将 led.c 文件添加到 Keil MDK 工程

  3. 确保函数名没有拼写错误

Logo

智能硬件社区聚焦AI智能硬件技术生态,汇聚嵌入式AI、物联网硬件开发者,打造交流分享平台,同步全国赛事资讯、开展 OPC 核心人才招募,助力技术落地与开发者成长。

更多推荐