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