I know this is a really noob question, but I have been bouncing around between various tutorials and trying to read the documentation. How do I add a libray to a project using lib_deps option?
The tutorials I come across on youtube, show that there is a way to download a library directly into my project, how ever when I open the library manager to download the library, I only have the option to download to global storage.
Then once the library is downloaded into the project, the INI file is tweaked to use the library when the program is complied.
Is there a straight forward instructions for adding a library to a project and setting up the dependencies?
Go to the library registry - either via your web browser, or via the libraries view of PIO Home
Search for you library, and open its information page
Click the installation tab once you’ve found your library, and copy whichever version of the lib_deps entry you want to use - ID, by name, by name and version, etc. Choose only one line.
Open your platformio.ini file, and add that reference under lib_deps (adding it if missing), with a single library reference per line if you have multiple libraries to declare.
i.e. for this project, I have several libraries, and I chose to reference by ID and specify specific versions of the libraries to be used, and then used comments to remind me what id related to what library.
Okay, if I am following your example correctly, I don’t need to actually download the library first. I just need to set up the dependency in the ini file. Then when I complied my program, the library will be downloaded.
why the IDE can’t see it !? I think my problem occurs due to the fact that CayenneLPP library belongs to framework = arduino and I’m using espressif32. but I don’t know how to integrate both so they can work together.
Why do you think the problem lies with the framework choice? Both your libs are Arduino libraries.
Just Ctrl+Shift+P → Rebuild IntelliSense in VSCode. PlatformIO will only recognize the library dependency after it sees an include in your code referencing it, not before that. Works perfectly fine.
I can’t reproduce that problem, with that exact platformio.ini you’re using. It may be possible that you have a corrupted library download. Delete the .pio/ folder of the project and retry building.
I did and i totally removed VSC( and all pio files from the registery ) and reinstall everything (didn’t install espressif tools this time) but the error remains the same !!
Remove the CMakeLists.txtfrom the project files (in the root and in the src/) folder. Make sure the only extensions you have installed are PIO, C/C++ by Microsoft, Python and Jupyter. If the project still not builds, please post the output the output of the project task “Advanced → Verbose Build” to pastebin.com/ and link to it here.
My Apologise, when i tried to rewrite the .cpp file again I noticed that I was including #include <CayenneLPPDecode.h> which is a different library than #include <CayenneLPP.h> and indeed pio is not going to find it. now it’s building successfully. Thank you.