No such file or directory error

Hi y’all! I’m having trouble compiling an ESP-IDF project. I get this error when I try to compile: “lib/MCP4551/MCP4551.h:1:10: fatal error: Wire.h: No such file or directory.” I’ve tried using both quotes and angle brackets and adding Wire to lib_deps in my platformio.ini file to no avail.

This is my VSCode showing file structure/the error/the include statement:

This is my platformio.ini file (I can’t put more than 1 screenshot so I’ve just copied/pasted it):

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = espidf
lib_deps = Wire, MCP4551

Any help would be greatly appreciated!

Your framework is ESP-IDF but you want to use all these Arduino libraries? These Arduino libraries will not be finding the Arduino core files without activating Arduino as an ESP-IDF component. See platform-espressif32/examples/espidf-arduino-blink at develop · platformio/platform-espressif32 · GitHub for an example on that. Remember, Arduino-ESP32 is an extension on top of ESP-IDF, and if you have an ESP-IDF project wanting to also use Arduino libraries instead of pure ESP-IDF, you need to include that component. Or switch the project to pure Arduino-ESP32 completely.

My bad, it seems you don’t use the Wire library from Arduino, but have a self-written one that is totally not Wire, just has the same name. Looking at

Library Manager: Installing Wire
Library Manager: Already installed, built-in library

seems to suggest a name conflict here, with the Wire library somehow still being found as a built-in Arduino library.

I’d suggest to remove the entire lib_deps expression from the platformio.ini (the auto-detection of the local libraries should work fine) and also rename the Wire library and its header file to something else.

Also note that I see see you using a src/main.c file but your libraries seem to be written in C++. To make proper use of those, your main.c should be a main.cpp (with the appropriate extern "C" on app_main() then), you include a header file declaring C++ classes from a C file.