0

I have a generic c++ library that i'd like to use in an arduino project without making changes to the library code. The library contains subfolders and files in the library include other files of the same library with includes of the form

#include "libraryroot/subfoldername/header.h"

I tried putting 'libaryroot' into C:/Users/Username/Documents/Arduino/libraries but while I can include headers that lie directly inside 'libraryroot' using #include <filename.h> (not #include <libraryroot/filename.h>), Arduino fails to find the headers these files include

How can I make use of such a library in Arduino without having to change the library?

  • 1
  • Check out Platform IO for visual studio code. It is a much better IDE and will let you this type of thing more easily. – geometrikal Nov 3 '19 at 9:42
  • @Juraj I already read this but I still didn't figure out how it can be done – user1282931 Nov 3 '19 at 12:29
0

To utilize subfolders with any name in an Arduino library, you must use the 1.5 library specification.

In libraries folder in your sketch folder, create a folder for the library. In this folder create a src subfolder and put the library source code into that subfolder. Then create a library.properties file in the root folder of the library with some dummy information. Fill the includes key with the main .h file of the library.

Documents/
  Arduino/
   libraries/
     FooLib/
      src/
       subfoldername/
        header.h
        some.h
        some.cpp 
       foolib.h 
       foolib.cpp
      library.properties

In code then use in #include the path with src folder as starting location.

#include <subfoldername/header.h>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.