Libraries - where does the IDE search for them?

I'm trying to build a project which is installed (under macOS) with a structure like:

~/ESP32-Marauder-Cheap-Yellow-Display/libraries
~/ESP32-Marauder-Cheap-Yellow-Display/esp32_marauder/esp32_marauder.ino

Oddly enough,

Version: 2.3.2
Date: 2024-02-20T09:57:46.613Z
CLI Version: 0.35.3

Copyright © 2024 Arduino SA

the IDE doesn't find the includes. But it seems that under

~/ESP32-Marauder-Cheap-Yellow-Display/libraries

all is there. When I reinstall libraries using the Library Manager, the project starts to find the include files.

How can I make that fit?

Each board type that you install, ie AVR, ESP32 etc may have board specific libraries, even libraries of the same name as for other boards

So, the IDE starts its library search in those board files. My ESP32 board library files are in C:\Users\Bob2\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.15\libraries

NOTE - this is Windows but I assume that that something similar exists on the Mac

If the compiler does not find a required library in the board specific location it then looks in the libraries folder of the Sketchbook folder. This folder holds libraries installed using the IDE Library Manager

As an alternative you can put library files in the same folder as the sketch and use the alternative form of #include, ie #include "libraryName,h" instead of #include <libraryName,h> This forces the compiler to look for the library in the sketch folder before moving on to do the normal search

I thought one might tweak some compiler/linker switches to use different search paths for Includes and Libraries.

And changing #include <LinkedList.h> to "LinkedList.h" didn't help either.

The alternative #include will only work if the library files are in the same folder as the sketch file. Is that where they are located ?

As I wrote in my initial post the libraries are located in ../libraries. Not where the .ino is.

But when I put the libraries folder into the same directory as the .ino file #include "LinkedList.h"still doesn't work.

But I'm approaching. Installing LinedList 1.3.3 by IvanSeidel made it work in <>.

You should put header files in the same folder with .ino. Not in the enclosed folders.

But where is that folder located ?

No surprise there if you used the Library Manager or installed it manually in the correct location, ie the libraries folder of the Sketchbook folder

No, this can't be it. There must be a way to install libraries of special versions local to the project without interfering with the standard libraries being installed in the standard folder under Arduino/libraries.

The project I downloaded from the author's site has the structure as I described in my initial post.

The respective libraries were all stored in ../libraries (relative to the folder with the .ino in it). What a mess that would produce when I put all header files into the same directoy as the .ino file.

There is. Put the project specific library files in the same folder as the .ino file and use the alternative version of #include using quotation marks

#include using double quotes

// library is in the same directory as the sketch
#include "mylib.h"
// library is in the src subdirectory of the sketch
#include "src/mylib/mylib.h"

If the library can not be found, the library search path will be extended with the below

  1. sketchbook / libraries.
  2. package / libraries for the bundled libraries (e.g. Servo or LiquidCrystal).
  3. package / core / libraries for system libraries like EEPROM or SPI.

Note that if you make a copy of a library in (2) and (3) above in the sketchbook / libraries directory, that copy will be used. So that is one way to override the default libraries.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.