# Serious return on investment issue over PIO library inclusion

Does it work for you?
I put the library- the folder from the GitHub zip file, into the project’s /lib folder. That’s what I’m supposed to do, right?

It never works the first time. Never.
I’ve been wrestling with it again all day.

Assuming it works for you, what am I doing wrong?
How is my PC different from your PC?

I’m having a completely bad experience. Arduino made it so easy. This is insane.

I recently reached a huge milestone. I made a BLE beacon work.
It did nothing for my state of mind. I got zero gratification from this huge thing, because I’m in the red as far as gratification goes here. This sucks.

Somebody, please tell me how to do it so it works every time without RESTARTING MY COMPUTER THIRTEEN TIMES. Explain why this software is such a huge time suck. Or tell me I should quit. Because that’s where we are. I can’t afford to waste this time for no fun.

Too many threads going on. It’s hard to keep up!

But here it is again…

Ok, here’s how it is for me. In a project that emulates the Arduino Serial interface for a book I’m currently writing.

platform.ini
src/testAVRusart.cpp
include/
lib/cBuffer/cBuffer.h
lib/cBuffer/cBuffer.cpp
lib/AVRusart/AVRusart.h
lib/AVRusart/AVRusart.cpp

• In src/testAVRusart.cpp I have #include "AVRusart.h".
• In lib/cBuffer/cBuffer.cpp I have #include "cBuffer.h". That header defines a circular buffer class.
• In lib/AVRusart/AVRusart.cpp I have #include "AVRusart.h". That header defines my USART class.
• Finally, in lib/AVRusart/AVRusart.h I have #include "cBuffer.h". Because the USART class has a pair of cBuffer class instances internally.

pio run compiles everything in src. When it sees the #include with a header file name in double quotes, it looks in:

• The current directory;
• The include directory;
• All sub-directories in lib.

The compilation works. I have nothing in platformio.ini that mentions lib_deps etc. It just works.

I do not have to restart VSCodium. I do not have to restart Linux.

In another project, migrated from the Arduino IDE, I use the “servo” library in the IDE. So, I have the option to:

• Install it globally - not a good idea as I’m using AVR for this project, but I also have some STM32 projects, it could lead to problems. Best avoided.
• Install it locally, just for this project. pio lib install servo
• Install it globally (no!) Or locally, using the pio home page in VSCodium.
• Get the compiler to install it for me, locally. lib_deps = servo.

I chose to use lib_deps.

Once again, no need to restart, pio run will find the library, or download it as required.

I do not have a “global” folder where I keep lots of useful libraries. All mine are self written so live in a subdirectory of lib, or live wherever pio run puts them if I have a lib_deps in the ini file.

• PlatformIO version 5.0.0 - it updated itself yesterday.
• VSCodium (not the latest) 64 bit.
• Linux Mint 19.3 64 bit.
• Dell Vostro 17" laptop, 8G RAM, Core duo (Yes, it’s over 10 years old!)
• Generating code for Atmel ATmega328, Arduino Uno and/or Arduino Duemilanove, both 16MHz, or my own “design”, Normduino running at 8MHz with no crystal to free up two extra pins. (ATMega328P 8MHz on a Breadboard – Rants & Raves – The Blog!)

With the number if problems you are having, I think there is either:

• Something wrong with your operating system;
• Something wrong with your PlatformIO installation;
• Something wrong in how or where you installed the libraries;
• Something wrong with the framework.

• Start simple. Try out a simple project with no libraries - blink. Get it working. So far so good!.
• Try another project, like servo, that uses a single library. Use lib_deps = servo. Compile. Did it work? Yes, move on, No, get in touch again. Post the output from the compiler. Post your ini file. Post the structure of your project folder. Post how you installed the library etc.

Please, post everything in one post. If you need to, you can edit a post using the pencil icon at the bottom. (I have to edit my posts all the time, spelling!)

Good luck.

Right, time for breakfast!

Cheers,
Norm.

2 Likes

Thank Norm,
Central to the issue I’m having is that there is apparently no ‘correct way to do it.’
It appears as if it’s all ad hoc techniques figured out in the lab.
I don’t trust it.
I can’t imagine any way I can find out if there’s a problem with my brand-new computer.
I can maybe reinstall PIO using Windows first. I’ll do that before I start today.

I don’t have any global libraries. I have a cache, and I’ve had to draw from it frequently when PIO can’t find it.

I’ve been trying to control controllable variables, but keeping notes is impossible. I only have three projects, but I’m generating a lot of folders of stuff that doesn’t work to get a handful that do work.

Something is consistently sending me into the library weeds, and I can’t imagine a way for me to investigate. I don’t use any firewalls.

Programs with no libraries don’t appear to give me any trouble, but there’s nothing I want to do without a library.

lib_deps = servo .

PIO goes online and finds ‘servo.h’ if I type this?
And it’s supposed to load even if the PIO library utility can’t find it?

I want one technique to use every time I want to include a library.
I don’t want to clog up my computer with all those files.
And I really need to stop paying attention to this.

Cheers,
joe

lib_deps does it all for you, exactly as you want to do.

So, lib_deps=file://C:\users\joe\path\to\your\cache\lib_folder_name should work. And should “install” the library into your project.

Not servo.h, the entire Servo library, headers, source code, examples, etc. I explained all this above.

Obviously, if it can’t be found, it will not be installed, and compilation will fail.

There is! It’s using lib_deps.

Cheers,
Norm.

1 Like