Multiple "libraries" - where SHOULD they be located?

I've been using Arduino for a few months. I've installed libraries and they always seem to end up in the same place. But there are some in other locations on my drive. Does anyone know where they should be located? Can I just copy them all to one place?

Most libraries (and new ones I install) are here:
...Documents / Arduino / libraries

Some libraries are here:
Program Files (x86) / Arduino / libraries

And some (like SPI) are located here:
Program Files (x86) / Arduino / libraries / hardware / arduino / avr / libraries

Hi
Some might be here:
C:\Users\xxxx\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries xxxx = your user

Documents/Arduino/libraries would be the libraries you have downloaded or added yourself.

The other locations are the default libraries that are packaged with the Arduino IDE, the two directories are likely for libraries that are usable on multiple hardware platforms and libraries that are specific to a particular hardware platform.

Ruilviana - You're right, there's a lot of them including this one:
\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.7.5\libraries\SPI

David - Thanks, I didn't realize there were more than one legitimate place for libraries to go.

So Now I want to make sure I'm using the "samd" version of SPI. How do I do that? My code includes SPI.h, how do I know which one it's grabbing?

Hi @tomthebomber
ops:
I think it's here:
C:\Users\xxxx\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\SPI

Hi
When selecting the type of microcontroller you are using the IDE selects the library.

Set the board you intend to upload, load your sketch, and make sure your "preferences" in the IDE is set to verbose, do a simple test compile or upload, the full library path is shown in the console.

Ok, thanks you've both helped a lot.
There's a huge hole in my knowledge about what's in these libraries that I didn't explicitly install.

For example, I need to create a second SPI interface. All the (incredibly confusing) documentation I've read talks about "wiring_private.h" which until today, I didn't know where it existed, or where to look for it even if I did. That stuff (SERCOM muxing etc.) is confusing enough without having to hunt for the files they're talking about.

At any rate, thanks.

Yep:
It is a P.I.T.A.
The IDE tracks in cache RAM on the PC where applicable libraries are located; which is why the IDE sometimes must be restarted after copying libraries.

Some of the old-timers will put libraries into the sketch folder, the .h and the .cpp and when started, the IDE will put the libs into tabs. Handy, but you will need to edit the #include lines to get the local copy and not a distant copy:

#include "filename.h"

you can also nest the libs relative to the sketch

#include "./mylibs/filename.h"

I've made my own "libraries" if you can call them that, and put them into my local folder but I'd rather keep libraries in the libraries folder in case I decide to move my source code.

Also, I'm using Notepad++ external editor, I find the Arduino editor a P.I.T.A.!
And I use tabs instead of spaces,
And I put my first "{" on the next line...
I'm a rebel.

Just my opinion, but maybe you should continue to keep your own libs in the sketch folder; it us sooo easy to achieve, just Zip the parent folder. New, similar project, just clone the folder. Diskspace is cheap. As you evolve the self written code, why go back and rehash what is working? In my world, Arduino/libraries are library-managed by library manager which is a constant churn thanks to Lady Ada.

Unless I don't understand what you meant, keeping the library in the project folder will create multiple copies of the library. This is exactly what I did. And if I make a modification to the library, I have to update multiple copies (which I never remember to do).

How about keeping your personal libraries under a folder in Arduino/libraries? That sounds like the best of both worlds.

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