PlatformIO problems finding (also marked in compile log) installed Libary if Libary is included "one more time"


I’ve created a Libary called “filemanager” it’s including the ArduinoJson Libary (installed with the inbuild Libary Manager).
this libary is included in a lot of other libarys within my project, every time it compiled without errors but if i want to include the filemanager Libary in my “new” Libary and i want to compile PlatformIO can’t find the installed ArduinoJSON Libary but at the right beginning of the compilation it mark ArduinoJSON as installed… if I comment out the include statement it compiles without errors again and find the ArduinoJSON libary needed by the filemanager…
I removed the .vscode and .pio folder, reinstall vsCode and pio but this can’t fix it…

I can’t manage this problem with google because i can’t find a problem like this :confused:
Hope anyone knows a solution…

I’m glad if anyone can check my File maybe i’ve not included it correctly?

filemanager.h (need ArduinoJSON - normally no problems using this Libary): ESPBase/filemanager.h at dev_linearWeb · j54j6/ESPBase · GitHub

logger.h (If i include the filemanager Libary here, ArduinoJson can’t be found anymore (comment line 57 out and it will compile without problems)): ESPBase/logger.h at dev_linearWeb · j54j6/ESPBase · GitHub


  1. Consider creating a library.json file for your library in which you declare your ArduinoJson dependency (docs)
  2. Have you tried different values for the lib_ldf_mode in the platformio.ini?
  3. All library declarations in

are of the old style / type since they don’t contain the owner or version information. See docs and example
4. Your referenced repo builds correctly for me by just cloning and pio run-ing it
5. Have you tried upgrading the PIO core version by open the CLI and doing pio ugprade --dev, then restarting VSCode?
6. What’s the full build log you get when you compile it and there’s an error?

Hey ^^,

thanks for your reply :slight_smile:

Point 1 and 3: I didn’t know that this way is the “old Style” :sweat_smile: - i definitely use your shown way in the future - thanks for that

Point 2: no i didn’t try that, i thougt thats only for my own Liabries ^^ - i’ll try it

Point 4: Yes, the Files i’ve referenced are correct (the branch dev_linear_web is correct)
Link: GitHub - j54j6/ESPBase at dev_linearWeb
I’ve downloaded it to test and it end’s with an error (log is linked below)

Point 5: Now i’ve upgraded my PIO but this doesn’t fix it for me :confused:

Point 6:thats the build log of the manually downloaded repo build (linked above → branch: dev_linear_web)
Link: > Executing task: C:\Users\Justin\.platformio\penv\Scripts\pio.exe run <Proc -

But i found out if i include all Libarys needed by the filemanager.h in my logger.h it will work without problems… (first i included ArduinoJson in the logger.h but then Platformio can’t find SPI.h, after including this it can’t find LittleFS…) - i don’t understand this problem… - is this helpful? :sweat_smile:

I appreciate your help ^^ - Thanks :slight_smile:

Due to surrounding the #include with a macro / #ifdef

and the default LDF mode, the dependencies are not picked up properly, since macros are not evaluated (see original documentation link I posted). I get the same error as you in the branch you’ve mentioned.

Once can also see that dependencies are missing in the dependency graph

|-- <led> (C:\Users\Max\ESPBase\lib\led)
|   |-- <logging> (C:\Users\Max\ESPBase\lib\logging)
|-- <logging> (C:\Users\Max\ESPBase\lib\logging)
|-- <moduleState> (C:\Users\Max\ESPBase\lib\moduleState)

because no sub-dependencies are there.


by doing lib_ldf_mode = chain+ will make it recongize the dependency

|-- <LittleFS(esp8266)> 0.1.0 (C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\LittleFS)
|-- <logging> (C:\Users\Max\ESPBase\lib\logging)
|   |-- <ArduinoJson> 6.17.2 (C:\Users\Max\ESPBase\.pio\libdeps\nodemcu\ArduinoJson)
|   |-- <SPI> 1.0 (C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\SPI)
|   |-- <LittleFS(esp8266)> 0.1.0 (C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\LittleFS)
|-- <network> (C:\Users\Max\ESPBase\lib\network)

and then reveal a programming mistake in the library

In file included from lib\logging\src\logger.cpp:1:0:
lib\logging\src\logger.h:39:18: error: expected unqualified-id before numeric constant
 #define logLevel 7
lib\logging\src/logging.h:15:13: note: in expansion of macro 'logLevel'
         int logLevel = -1;
In file included from lib\filemanager\src/filemanager.h:7:0,
                 from lib\logging\src\logger.h:63,
                 from lib\logging\src\logger.cpp:1:
lib\logging\src/logging.h: In static member function 'static int logger::getLogLevel()':

you’ve named a variable and a macro the same way.

Again the LDF mode and the dependencies can all be set in the library.json file too if you decide to create one for your library.

If I change logLevel to m_logLevel in the logging.h (2 occurrences), the result is

Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [======    ]  58.3% (used 47796 bytes from 81920 bytes)
Flash: [====      ]  39.4% (used 412040 bytes from 1044464 bytes)
============== [SUCCESS] Took 39.01 seconds ==============

A compiling firmware.

Thank you so much for your help, the lib_ldf_mode solves my problem ^^ - The other is because of my deprecated Libary “logging.h” this libary will be replaced by the logger.h Lib - i fixed this only local to keep the data the same as at the beginning of this topic ^^ - but thanks a lot for your help :slight_smile:

I think i need to read the PIO Documentation to prevent fails like that in the future ^^

Thank you again you helped me so much :slight_smile:

Greetings from Germany