STM32CubeIDE编译Semtech SDK报错:文件已存在却提示找不到
针对在STM32CubeIDE编译仅支持Keil和GNU Makefile的Semtech SDK时,出现lr11xx_bootloader_types.h: No such file or directory的问题,可按以下步骤排查:
验证编译命令的包含参数:从编译日志看,当前
arm-none-eabi-gcc命令中没有任何-I(指定包含目录)参数,说明CubeIDE的Build配置未正确同步到makefile。进入C/C++ Build -> Settings -> MCU GCC Compiler -> Includes,确认添加的路径是相对于项目根目录的相对路径(比如./lr11xx/lr11xx_driver/src)或使用CubeIDE变量(如${workspace_loc:/${ProjName}/lr11xx/lr11xx_driver/src}),保存后执行Project -> Clean再重新编译。检查subdir.mk生成情况:报错指向
lr11xx/common/printers/subdir.mk,打开该文件查看是否包含对应头文件目录的INCLUDES += -I"../../lr11xx_driver/src"(路径根据实际层级调整)。如果没有,删除项目的Debug/Release目录,重新执行Build -> Generate Makefiles Automatically后再编译。确认头文件引用与宏定义:
- 确保
#include "lr11xx_bootloader_types.h"中头文件的大小写与实际文件完全一致(GNU工具链区分大小写); - 检查SDK配置头文件(如
lr11xx_config.h)是否存在控制头文件路径的宏定义,若有需在C/C++ Build -> Settings -> MCU GCC Compiler -> Preprocessor中添加对应宏。
- 确保
修正路径分隔符:CubeIDE中添加包含目录时,将Windows风格的
\替换为GCC支持的/,避免路径解析错误。
编译报错日志
17:29:44 **** Incremental Build of configuration Debug for project gnss_test_executable_02 **** make all arm-none-eabi-gcc "../lr11xx/common/printers/lr11xx_bootloader_types_str.c" -mcpu=cortex-m4 -std=gnu11 -g3 -c -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"lr11xx/common/printers/lr11xx_bootloader_types_str.d" -MT"lr11xx/common/printers/lr11xx_bootloader_types_str.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "lr11xx/common/printers/lr11xx_bootloader_types_str.o" In file included from ../lr11xx/common/printers/lr11xx_bootloader_types_str.c:1: ../lr11xx/common/printers/lr11xx_bootloader_types_str.h:3:10: fatal error: lr11xx_bootloader_types.h: No such file or directory 3 | #include "lr11xx_bootloader_types.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make: *** [lr11xx/common/printers/subdir.mk:40: lr11xx/common/printers/lr11xx_bootloader_types_str.o] Error 1 "make all" terminated with exit code 2. Build might be incomplete. 17:29:48 Build Failed. 2 errors, 0 warnings. (took 3s.298ms)
内容的提问来源于stack exchange,提问作者Nicolas Quiroga

