ESP32:如何修复 ESP-IDF 致命错误:esp_console.h: No such file or directory
问题
构建 ESP-IDF 项目时,你可能会遇到以下错误:
esp_console_error_log.txt
/home/user/MyProject/main/main.cpp:7:10: fatal error: esp_console.h: No such file or directory
7 | #include <esp_console.h>
| ^~~~~~~~~~~~~~~
compilation terminated.解决方案
你需要确保项目中包含 console 组件。这可以通过修改 main/CMakeLists.txt 文件将 console 组件添加为依赖项来实现。
你可以在 idf_component_register 函数中添加 REQUIRES console 行。以下是修改 main/CMakeLists.txt 文件的方法:
main_cmakelists_add_console.cmake
idf_component_register(
SRCS "main.cpp"
INCLUDE_DIRS "../include"
REQUIRES console
)If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow