Including a library from another library (not main sketch)

Hi all

To have my code organized in a more intuitive way and promote code re-use, i like to have it spread out in several files. Not necessarily a new library, but just a C file and header file with function prototypes.

My issue is trying to include standard (or imported) libraries in these files. I always end up having to copy the library from the libraries folder into my sketch folder, as a normal include always fails.

From research it seems there is no way around this, but i could not find a confirmation.

Is this correct or is there a easier fix?

Thank You

I'm not sure what you mean.

I often copy files from a library into my project, either *.cpp, *.h or *.ino. Those file can include libraries without problem.

When you include a *.h of your own project : #include "duck.h"
When you include a imported library or normal library : #include <seagull.h>
There is a certain way and order that Arduino add all the files of a project together. I think it is left to right, so you can include something in the main project file and that should be okay.

Sometimes I have to remove include files or add them, sometimes I use a general include.h file. I'm still not sure how it is organized, but in the end I have it working :slight_smile:

Without seeing any of your code or error messages all this is pure guesswork, but this might help.

Libraries are only copied into a temporary area and compiled as part of your sketch if there is an #include for them in the main .ino file (main sketch).

So if A uses B which uses C (A being the main sketch) then A has to #include "C" as well as "B".

How to avoid the quirks of the IDE sketch file pre-preprocessing

Tks for the tips.

Will try them