ESP32 lib dependency works on Arduino but not ESP-IDF

I’m struggling to get code that uses an external GitHub library to compile using ESP-IDF but which works fine if I select the Arduino framework

Here is my platform.ini

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = espidf
monitor_speed = 115200
lib_deps = 
    https://github.com/collin80/esp32_can.git

This is the main.c

#include "esp32_can.h"

void app_main() {
}

and this is the error I see when compiling

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 1.12.4 > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-espidf 3.40001.200521 (4.0.1) 
 - tool-cmake 3.16.4 
 - tool-esptoolpy 1.20600.0 (2.6.0) 
 - tool-ninja 1.9.0 
 - toolchain-esp32ulp 1.22851.190618 (2.28.51) 
 - toolchain-xtensa32 2.80200.200226 (8.2.0)
Reading CMake configuration...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/esp32doit-devkit-v1/esp-idf/src/main.c.o
Generating LD script .pio/build/esp32doit-devkit-v1/esp32_out.ld
Generating partitions .pio/build/esp32doit-devkit-v1/partitions.bin
src/main.c:1:10: fatal error: esp32_can.h: No such file or directory

*******************************************************************
* Looking for esp32_can.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:esp32_can.h"
* Web  > https://platformio.org/lib/search?query=header:esp32_can.h
*
*******************************************************************

 #include "esp32_can.h"
          ^~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/esp32doit-devkit-v1/esp-idf/src/main.c.o] Error 1
Compiling .pio/build/esp32doit-devkit-v1/esp-idf/app_trace/app_trace.c.o
============================================================ [FAILED] Took 8.62 seconds ============================================================
The terminal process "platformio 'run'" terminated with exit code: 1.

I read that I need to include the header file in the include directory, but I never needed to do this with the arduino framework which compiles just fine.

Does anyone know why it would work with arduino but no esp-idf?

I should have added that the files look to be available but not on the include path

$ find . -name esp32_can.h
./.pio/libdeps/esp32doit-devkit-v1/ESP32_CAN@src-15ea4be389de3e1bb471441707ee5ba1/src/esp32_can.h
./.pio/libdeps/esp32doit-devkit-v1/ESP32_CAN/src/esp32_can.h

Well the library only has a library.properties which is an Arduino format. Thus it’s implied that it only works for Arduino.

If it had a library.json in PlatformIO format delcaring its frameworks as both Arduino and ESP-IDF, it at least be recognized as a compatible library. Otherwise PlatformIO will supress non-compatible libraries.

If you are absolutely sure this library is also supposed to work for pure ESP-IDF (which I also personally doubt), you can set the lib_compat_mode as the docs say. in the platformio.ini

lib_compat_mode = off

What you identified makes sense now. Many thanks for your advice.

I may ask the author to see if it is possible for his library to support both Arduino and ESP-IDF

Have you found the solution, Cause I’m facing the same issue.