Now, when I try to build the project, the console says
[...]
Compiling .pio\build\nodemcuv2\lib8ad\MyLib\MyLib.cpp.o
lib\MyLib\src\MyLib.cpp:2:26: fatal error: PubSubClient.h: No such file or directory
**********************************************************************
* Looking for PubSubClient.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:PubSubClient.h"
* Web > https://platformio.org/lib/search?query=header:PubSubClient.h
*
**********************************************************************
#include <PubSubClient.h>
^
compilation terminated.
I would have expected that PIO automatically figures out that PubSubClient needs to be downloaded and makes it available within the project.
A workaround is to put PubSubClient to lib_deps in platformio.ini, but I think it would be a cleaner approach if my local lib would manage its dependencies on its own and the main project doesn’t even know about the “nested” ones…
Is this possible? Am I doing sth. wrong?
Thanks for your feedback!
thanks for your answer.
I took a look at my dependency graph, but it shows only one layer and no nested dependencies (esp-libraries is another dependency from one of my GitHub repositories):
[...]
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <esp-libraries> #14a83c0
|-- <ESP8266WiFi> 1.0
|-- <MyLib>
Building in release mode
Compiling .pio\build\nodemcuv2\src\main.cpp.o
[...]
Even if I set lib_ldf_mode to deep in my platformio.ini (in the root project), it does not change anything:
[...]
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ deep, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <esp-libraries> #14a83c0
|-- <ESP8266WiFi> 1.0
|-- <MyLib>
Building in release mode
Compiling .pio\build\nodemcuv2\src\main.cpp.o
[...]
UPDATE
When I run the build step in verbose mode (-v), it says that the PubSubClient library is being ignored. But why is that?
[...]
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
Warning: Ignored `PubSubClient` dependency for `MyLib` library
Dependency Graph
|-- <ESP8266WiFi> 1.0 (C:\Users\Philippe\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi)
|-- <MqttHandler> (C:\development\platformio\morse-project\lib\MqttHandler)
Building in release mode
[...]
oh, thanks for pointing that out - actually the library.jsonis placed within the MyLib folder. It has just the wrong indentation in my first post. So here’s the correct structure:
Maybe it doesn’t like it when you specify the library without a version number. Try using the documentated short form.
Also you’re not putting in any of the values which are marked as required in the doc – your library must have at least a name, version, description, keywords and repository in the library.json.
Try with a library.json like:
{
"name": "MyLib",
"description": "My test library",
"keywords": "keyword1,keyword2",
"version": "1.0.0",
"repository":
{
"type": "git",
"url": "<your actual .git link here>"
},
"dependencies":
{
"PubSubClient": "^2.8"
}
}
# This is before deleting the ppl directory from libdeps:
force-majeure % pio lib install lib/ppl
Library Storage: /Users/josh/github/pyrogenic/force-majeure/.pio/libdeps/nanoatmega328new
Library Manager: ppl @ 0.0.0+20210307111859 is already installed
# This is after deleting the ppl directory from libdeps:
force-majeure % pio lib install lib/ppl
Library Storage: /Users/josh/github/pyrogenic/force-majeure/.pio/libdeps/nanoatmega328new
Library Manager: Installing file://lib/ppl
Library Manager: ppl @ 1.1.0 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing milesburton/DallasTemperature @ ^3.9.1
Library Manager: DallasTemperature @ 3.9.1 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing paulstoffregen/OneWire @ ^2.3.5
Library Manager: OneWire @ 2.3.5 has been installed!