Search code examples
c++arduinocommand-line-interfacearduino-cli

Including a locally installed library in Arduino


How do I include a local file? This is my project structure (with multiple sketches):

(project root)
    - some_config.json
    - SketchOne/
        - SketchOne.ino
    - SketchTwo/
        - SketchTwo.ino
    - lib/
        - lib_1/
            - some.h

From SketchOne/SketchOne.ino, I want to include lib/lib_1/some.h. I've tried the following(s):

#include "lib/lib_1/some.h"
#include <lib/lib_1/some.h>
#include "lib_1/some.h"
#include <lib_1/some.h>

Note: I use the CLI (arduino-cli)


Solution

  • In Arduino projects are called "sketches". The name of the main ino file of the sketch must match the name of the sketch folder. CLI builds one sketch at time.

    Sketches are in file system organized into a folder called "sketchbook". The sketchbook folder should containing a special folder named "libraries". Folders in the libraries folder are treated as libraries. There are two forms of library folder in the file system: old and new.

    See the sketch build process too.