Too many threads going on. It’s hard to keep up!
I answered over on your “tone” thread.
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. (http://qdosmsq.dunbar-it.co.uk/blog/2019/02/atmega328p-8mhz-on-a-breadboard/)
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.
My advice.
- 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.