solved: location of directory "libraries"?

Hi,
after installation of the IDE there is a directory "libraries" on the installation path, e.g. C:\Programme\Arduino\libraries.

For the installation of library files from other projects it is recommended to generate an extra directory "libraries" below the directory "examples" and to copy the files there.

In my installation I splitted the files from installation and the files from other projects and my own projects on a separate partition. I also moved the "examples" directory from the installation path to the separate partition. The path to that partition is set in the menue "file-Preferences-Sketchbook location" as "H:\Arduino\examples".

The directory structure in the installation path now is:

C:\Programme\Arduino\drivers
C:\Programme\Arduino\examples\     --> moved to H:\Arduino\
C:\Programme\Arduino\...
C:\Programme\Arduino\lib
C:\Programme\Arduino\libraries\
C:\Programme\Arduino\...

The directory structure in the extra partition is:

H:\Arduino\examples\01.Basics
H:\Arduino\examples\...
H:\Arduino\examples\otherProject
H:\Arduino\examples\...
H:\Arduino\examples\libraries\Adafruit_CC3000_Library\
H:\Arduino\examples\libraries\Adafruit_Circuit_Playground\
H:\Arduino\examples\libraries\Bridge
H:\Arduino\examples\libraries\...
H:\Arduino\examples\libraries\specificlib
H:\Arduino\examples\libraries\...
H:\Arduino\examples\...
H:\Arduino\examples\project1
H:\Arduino\examples\project2
H:\Arduino\examples\...

During runup the IDE looks for updates and from time to time libraries are updated. Up to now i did'nt care where the updates are stored to. But recently I detected that some of the library names identically occor in C:\Programme\Arduino\libraries\ and in H:\Arduino\examples\libraries.
And now two questions rise up:

  1. Where are the files from a library update stored to, C:\Programme\Arduino\libraries or H:\Arduino\examples\libraries\ ?

  2. When in a sketch libraries are included, where are they taken from, C:\Programme\Arduino\libraries or H:\Arduino\examples\libraries\ ?

SupArdu:
For the installation of library files from other projects it is recommended to generate an extra directory "libraries" below the directory "examples" and to copy the files there.

That's absolutely wrong. The Arduino IDE will not recognize libraries installed to that location.

You should also never install anything to the Arduino IDE installation folder, as it will be lost whenever you update to a new version of the Arduino IDE.

SupArdu:

  1. Where are the files from a library update stored to, C:\Programme\Arduino\libraries or H:\Arduino\examples\libraries\ ?

The are installed to {sketchbook folder}\libraries, where {sketchbook folder} is defined at File > Preferences > Sketchbook location.

SupArdu:
2) When in a sketch libraries are included, where are they taken from, C:\Programme\Arduino\libraries or H:\Arduino\examples\libraries\ ?

When multiple libraries are found that match an #include directive in your code, the Arduino IDE tries to be smart about deciding which is the correct library to use. The decision is based on multiple factors:

  • Architecture match between the board (as determined by the architecture folder name of its hardware package) and the library (as determined by the architectures field in library.properties). Explicit match > wildcard match > mismatch. If a library has no library.properties or no architectures field in library.properties, that is considered a wildcard architecture match.
  • Filename/folder name match. If the library folder name matches the filename in the #include directive, that library is given preference.
  • Library location. {sketchbook folder}/libraries > {hardware package folder}/libraries > {Arduino IDE installation folder}/libraries

Libraries bundled with hardware packages other than the one for the board you are compiling for are ignored so they don't even come into the equation.

All else the same, the library at {sketchbook folder}\libraries will be used.

This system usually does a good job of picking the correct library but in some cases it does end up grabbing a different library than you had intended. To make this less of an issue, the Arduino IDE will display a list of the matching libraries it found and which it used in the black console window at the bottom of the Arduino IDE window. When it thinks the information is not critical, it may only show it if you have File > Preferences > Show verbose output during compilation enabled. So if you're in doubt, it's a good idea to turn that option on at least for one compilation.