Local lib install


#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


#2

You need http://docs.platformio.org/en/latest/librarymanager/ldf.html

Please note that you should specify in lib_extra_dir a path to folder which contains libraries. As I can see, you specified direct path to a library. This is incorrect.


#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


#4

Could you provide a simple project to reproduce this issue?


#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?