ESP32 IDF C++ adding private Libs

I am very new to this (platformio) and esp32 too…
I want to use platfromio, but don’t understand the simplest of things
I added a bunch of .h and .c files in LIBS
as cpp_utls<files> (lots of .c and .h) files

then include them as
#include <BLEDevice.h>

and platform IO no can find…

Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
Collected 0 compatible libraries
Scanning dependencies…
No dependencies
Compiling .pioenvs\esp32dev\src\main.o
src\main.cpp:9:23: fatal error: BLEDevice.h: No such file or directory

  • Looking for BLEDevice.h dependency? Check our library registry!
  • CLI > platformio lib search “header:BLEDevice.h”
  • Web > PlatformIO Registry

Seems like you want to use the PlatformIO Registry library. Go to your platformio.ini and add the line

lib_deps = 1841

I don’t know what you do with that other library code of yours but that doesn’t seem to cause an error yet…

no I not using ARDUINO platform
just using his general C++ libs
I thought PIO would take care of the .c/,h files automatically as it
should search the /lib path no?

Can you show me where the BLEDevice.h is in the ESP-IDF platform? This seems to come from an Arduino library.

I don’t know what the problem is yet with your custom files in the lib folder. Is that BLEDevice.h file there?

its in \lib\cpp_utls\BLEDevice.h

Hmm can you upload your project as a ZIP file on google drive / dropbox? I could take a quick a look as to why it’s not working.


there is nothing to the code (YET)

You had a problem with the LDF compatibility mode (docs). Change the platformio.ini to

platform = espressif32
board = esp32dev
framework = espidf
lib_compat_mode = off

I also fixed “build-flags” to “build_flags”.

There is a in your cpp_utils folder by which PIO decides that this is an Arduino library and cannot be used on espidf. It even shows the library name as

Dependency Graph
|-- <ESP32 BLE Arduino> v0.1.0 (C:\Users\Maxi\Desktop\testCpp\lib\cpp_utils)

I really don’t know how this is supposed to work though, it seems like there are like 15 different libraries thrown into this folder, even with some Arduino referenes? (as the file

The compilation stops because cJSON.h is nowhere to be found in the folder but JSON.cpp needs it. Once you add it from GitHub - DaveGamble/cJSON: Ultralightweight JSON parser in ANSI C (only cJSON.c and cJSON.h) it complains that the ESP32CPP class inside a MFRC522 driver cannot be found, whereever that class is. I would start to only pick out the needed files and start building the project from that, instead of throwing every possible CPP/H file into one big folder and try to compile it all.

1 Like

yes… he uses these classes to make the Arduino support
but can be used without
ok. I did this
lib/ble/ only the BLE*.h and BLE*.c

and THANKS on catching the build_flags :slight_smile:

made some progress

In file included from lib/BLE/BLECharacteristic.h:17:0,
from lib/BLE/BLEServer.h:19,
from lib/BLE/BLEDevice.h:18,
from src\main.cpp:9:
lib/BLE/BLEDescriptor.h:16:22: fatal error: FreeRTOS.h: No such file or directory
that include is part of ESP32-IDF

infact my main has “#include “freertos/FreeRTOS.h””

this is whats in the BLEDescriptor.h

#include “FreeRTOS.h”

I really hate how includes work. or don’t work… just search the paths… and it would be found

do I really need to put the folder??!?!?

You can add

-I $PIOHOME_DIR/packages/framework-espidf/components/freertos/include/freertos

to your build_flags for that if you want.

I gots it… that header wasn’t reference to the IDF, it was Niel’s little cpp helper util
(it was in the cpp_utils folder)
added it to


Successful build!


there are a couple of warnings… looks like from the IDF itself

C:\Users\mitchjs.platformio\packages\framework-espidf\components\log\log.c: In function ‘esp_log_buffer_hex_internal’:
C:\Users\mitchjs.platformio\packages\framework-espidf\components\log\log.c:378:16: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
buffer += bytes_cur_line;

anything to worry about?

Great that it works now.

If you see a bug in the ESP-IDF framework better report it to the source (esp-idf/log.c at master · espressif/esp-idf · GitHub) at their github.