How to include a custom library

Hi, I tried to create my first private library and add it to the lib directory. My structure is effectively as follows:

lib
|-- myLibrary
---    |-- lib (files that are needed by the source files
---    |-- src
---        |-- libfile.h
---        |-- libfile.cpp
---        |-- FolderA
--- ---            |-- libfileA.h
    |-- library.properties

my library.properties has the following contents

name=myLibrary
version=1.0.0
author=michox
maintainer=michox
sentence=Define a repository of Peripheral sensors, actuators, and external devices
paragraph=
category=Device Control
url=https://github.com/myLibrary
architectures=*

however, when I try to include the file from my project src or include directory it will fail to build. I want to include libfileA.h and I tried several methods but at the moment I can’t even include libfile.h. I tried

#include "libfile.h"
#include "myLibrary/src/libfile.h"
#include <myLibrary/libfile.h"

but nothing worked. I am really clueless at this point and some help would be really appreciated!

I find the following structure works best for PlatformIO libraries:

lib
|
+---MyLib
        |
        +----- MyLib.h
        +----- MyLib.cpp

I don’t bother with the src directory beneath lib/MyLib. Everything works fine for me that way.

Cheers,
Norm.

Hey Norm, Thanks for the tip. Unfortunately, it is a complex library with about 5 levels, I just simplified it here, a flat structure is not possible in my use case.

1 Like

Only libraries of the documented structure are supported, sadly. For you it might even help to put all source files and sub-folders into src/.