Github lib_deps vs using ide libraries

I’m using pio in vscode on windows. I went to the libraries section of pio home and installed TelnetStream. I included it in my main.cpp using #include <TelnetStream.h>. Compiling failed with header file not found. Then I tried #include "TelnetStream.h" and it also failed.

So then I added lib_deps = https://github.com/jandrassy/TelnetStream to platformio.ini and it compiled ok. But I still have a problem. VSCode is still showing the header file is missing with a red line under the code.

How do I fix this and why didn’t the normal PIO install work?

Adding the library via the library GUI to the project should have the same effect as adding

lib_deps =
     jandrassy/TelnetStream @ ^1.2.1

to the platformio.ini.

I just tested that.

Before:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

Adding the lib to my project

after

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = jandrassy/TelnetStream@^1.2.1

But you are right that it will show a red squigly line for the include header

This is because a reference to the library has to be first added to the project (via an #include statement), and then the project has to be either built or a Ctrl+Shift+P → Rebuild IntelliSense must be executed. This is because the library dependency finder will only add the used libraries to the include path, and at the time of adding the library to the project, there is no reference to in the code. This is the way the LDF works.

You see after I execte a Ctrl+Shift+P → Rebuild IntelliSense

that the red line is gone, and all subfunctions, classes and objects, like the TelnetStream are found.

Thanks. So adding the lib with the UI just appends lib_deps to my platformio.ini? It didn’t do that. And the lib appears in my installed list.

I will check out the rest of your reply about the intellisense and I will probably have more questions. :slight_smile: