v3xX
November 8, 2018, 10:53pm
#1
Hello everone.
I am trying to install my own classes to the Libary manager so I can use them in different projects.
I tried
platformio lib --storage-dir /.../MyClass install
platformio lib --storage-dir /.../MyOtherClass install
There are no errors, but did it do what I want, because when I try to use MyClass.h I get an error
Error: Could not find `MyOtherClass.h` dependency for `MyClass` library
There are .json files in the folders and MyClass has a dependency on MyOtherClass
"dependencies":
{
"name": "MyOtherClass.h",
"authors": "Sh",
"frameworks": "arduino"
},
and I also reference the libary folder in my platform.ini file
[env:myenv]
lib_extra_dir = /.../library
Is there a way to ‘install’ my custom classes (which also reference other classes in my library)?
These classes are not yet finished and will be changed constantly. For now I just copied the updated versions into each project manually, which is very tedious.
Maybe there is an easier way.
Thanks
You need Library Dependency Finder (LDF) — PlatformIO latest documentation
Please note that you should specify in lib_extra_dirs a path to folder which contains libraries. As I can see, you specified direct path to a library. This is incorrect.
v3xX
November 20, 2018, 6:46am
#3
The libary folder contains all my custom classes.
/.../library/MyClass/MyClass.h
/.../library/MyCustomClass/MyCustomClass.h
/.../library/MyOther/MyOtherClass.h
every class folder has a .json and .properties file, but I dont think they are only when I want to use my libraries via Git
Could you provide a simple project to reproduce this issue?
v3xX
December 26, 2018, 7:09pm
#5
I tried to work around the problem but the libraries I want to use are getting to extensive.
A simple example would be:
main.cpp
#include <Arduino>
#include <Chipset/Testchip.h>
Testchip TS = Testchip();
void setup() {}
void loop() {}
and in the platformio.ini
lib_extra_dirs = /media/.../libraries
where the Chipset is stored externaly using following directory structure
|-- libraries
–|-- Chipset
–|-- Testchip
–|--|–> Testchip.h
–|--|–> Testchip.cpp
where Testchip.h
#ifndef TESTCHIP_H
#define TESTCHIP_H
class Testchip {
public:
volatile uint8_t b;
Testchip();
}
#endif
and Testchip.cpp
#include "Testchip.h"
Testchip::Testchip() {
b = 5;
}
I always get the error
undefined reference to `Testchip::Testchip()'
which indicates that the file is not linked.
I tried every version of “Chipset/Testchip/Testchip.h” and with the other guards < > but it doesnt seem to find the file.
Is there maybe another setting to enable linking of header and body files?
Should it be #include <Testchip/Testchip.h>
?