如何修复 PlatformIO fatal error: stm32f429i_discovery_lcd.h: No such file or directory

问题:

你正在尝试使用 LCD_DISCO_F429ZI 库编译你的 PlatformIO 应用程序,但你看到类似这样的错误消息

platformio_error.txt
 #include "stm32f429i_discovery_lcd.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\disco_f429zi\src\main.o] Error 1
In file included from .pio\libdeps\disco_f429zi\LCD_DISCO_F429ZI_ID2432\LCD_DISCO_F429ZI.cpp:19:0:
.pio\libdeps\disco_f429zi\LCD_DISCO_F429ZI_ID2432\LCD_DISCO_F429ZI.h:25:10: fatal error: stm32f429i_discovery_lcd.h: No such file or directory

解决方案

首先,确保 BSP_DISCO_F429ZIplatformio.ini 中列为库依赖,如下所示:

platformio_ini_example.txt
[env:disco_f429zi]
platform = ststm32
board = disco_f429zi
framework = mbed
lib_deps =
    LCD_DISCO_F429ZI
    BSP_DISCO_F429ZI

替换行

stm32_include_fix.c
#include "stm32f429i_discovery_lcd.h"

LCD_DISCO_F429ZI.h 中为

stm32_include_replacement.c
#include "Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.h"

Check out similar posts by category: C/C++, PlatformIO