Private library not finding one of other private libraries

It seems one of my private libraries doesn’t find the otheR.

Part(s) of build log:

LDF Modes: Finder ~ deep, Compatibility ~ soft
Ignored library C:\Users\PsychoX\.platformio\packages\framework-arduinopico\libraries\Adafruit_TinyUSB_Arduino
More details about "Library Compatibility Mode": https://docs.platformio.org/page/librarymanager/ldf.html#ldf-compat-mode
Found 58 compatible libraries
Scanning dependencies...
Dependency Graph
|-- TFT_eSPI @ 2.5.43 (License: Unknown, Path: D:\Projects\+embedded\picOOscilloscope\.pio\libdeps\pico\TFT_eSPI)
|   |-- SPI @ 1.0 (License: Unknown, Path: C:\Users\PsychoX\.platformio\packages\framework-arduinopico\libraries\SPI)
|   |-- LittleFS @ 0.1.0 (License: Unknown, Path: C:\Users\PsychoX\.platformio\packages\framework-arduinopico\libraries\LittleFS)
|-- CRC32 @ 2.0.0 (License: Unknown, Path: D:\Projects\+embedded\picOOscilloscope\.pio\libdeps\pico\CRC32)
|-- tft (License: Unknown, Path: D:\Projects\+embedded\picOOscilloscope\lib\tft)
|   |-- TFT_eSPI @ 2.5.43 (License: Unknown, Path: D:\Projects\+embedded\picOOscilloscope\.pio\libdeps\pico\TFT_eSPI)
|   |   |-- SPI @ 1.0 (License: Unknown, Path: C:\Users\PsychoX\.platformio\packages\framework-arduinopico\libraries\SPI)
|   |   |-- LittleFS @ 0.1.0 (License: Unknown, Path: C:\Users\PsychoX\.platformio\packages\framework-arduinopico\libraries\LittleFS)
|   |-- utils (License: Unknown, Path: D:\Projects\+embedded\picOOscilloscope\lib\utils)
|-- EEPROM @ 1.0 (License: Unknown, Path: C:\Users\PsychoX\.platformio\packages\framework-arduinopico\libraries\EEPROM)
|-- SPI @ 1.0 (License: Unknown, Path: C:\Users\PsychoX\.platformio\packages\framework-arduinopico\libraries\SPI)
|-- utils (License: Unknown, Path: D:\Projects\+embedded\picOOscilloscope\lib\utils)
|-- logging (License: Unknown, Path: D:\Projects\+embedded\picOOscilloscope\lib\logging)
Building in release mode
[...]
In file included from lib\tft\src\touch.cpp:1:
lib\tft\src\touch.hpp:4:10: fatal error: logging.hpp: No such file or directory

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

    4 | #include <logging.hpp>
      |          ^~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\pico\lib4ef\tft\touch.cpp.o] Error 1
[...]

I have 3 private libraries:

  • The tft private library provides some adapting and basic UI elements over the TFT_eSPI library (from repository).
  • The logging - another private library (maybe some day could go public), basically 2 headers that provide simple macros like LOG_ERROR etc adapting depending on platform (Pico/ESP/Arduino/AVR)
  • The utils private library, stuffed with few random utils

The tft is only used from main code. Both the utils and logging should used by both main code AND tft - problem is, the LDF only finds utils while in tft context.

I tried:

  • adding lib_ldf_mode = deep to platformio.ini, not much changes.
  • adding #include <logging.hpp> to both hpp and cpp file from - also doesn’t help (just errors in header instead of source file due to includes ordering)

Why utils works but logging not? Werid.

Can you show the folder / file structure where youre files are located?

Here is screenshot:

If it isn’t enough let me know. I can also tree -d the directory, but it’s a lot of files.

Have you tried deep+ ?

.
β”œβ”€β”€ include
β”œβ”€β”€ lib
β”‚   β”œβ”€β”€ LibA
β”‚   β”‚   β”œβ”€β”€ LibA.cpp
β”‚   β”‚   └── LibA.h
β”‚   β”œβ”€β”€ LibB
β”‚   β”‚   β”œβ”€β”€ LibB.cpp
β”‚   β”‚   └── LibB.h
β”‚   β”œβ”€β”€ LibC
β”‚   β”‚   β”œβ”€β”€ LibC.cpp
β”‚   β”‚   └── LibC.h
β”‚   └── README
β”œβ”€β”€ src
β”‚   └── main.cpp
β”œβ”€β”€ test
β”œβ”€β”€ .gitignore
└── platformio.ini

LibA : independend
LibB: depends on LibA
LibC: depends on LibA & LibB

LibA

LibA.h

#pragma once

void functionFromLibA();

LibA.cpp

#include "LibA.h"
#include <HardwareSerial.h>

void functionFromLibA() {
    Serial.println("functionFromLibA");
}
LibB

LibB.h

#pragma once

void functionFromLibB();

LibB.cpp

#include "LibB.h"
#include <LibA.h>
#include <HardwareSerial.h>

void functionFromLibB() {
    functionFromLibA();
    Serial.println("functionFromLibB");
}
LibC

LibC.h

#pragma once

void functionFromLibC();

LibC.cpp

#include "LibC.h"
#include <HardwareSerial.h>

#include <LibA.h>
#include <LibB.h>

void functionFromLibC() {
    functionFromLibA();
    functionFromLibB();
    Serial.println("functionFromLibC");
}

It looks like this is from your picOOscilloscope repo?
If so, can you push the latest version to the repo?

Solution 1

Using deep+ works for me. Thanks for your help and dedication.

Solution 2

I was thinking: Maybe the issue is because there is logging.hpp in both main files (src folder) and the logging private library? However, it shouldn’t be a thing, since private library compilation context shouldn’t even include main files, no?

So, I just tried renaming the file into anything else - and it also helps (working on deep, and even default chain LDF mode (if #include from header file)).

Why?

Now question β€œwhy?” remains. Looks like LDF is a bit bugged? I am not 100% why… For sure it’s annoying and undesirable behaviour. For now I will leave this issue/topic open I guess.


I will update the repo in like hour when I finish current commit - I am trying to split code from src into few private libraries, with hope that will ease testing. Again thank for your help & interest.

1 Like