Library File locations

I often have problems where the Arduino IDE can't find a library file. Can someone explain exactly where the IDE looks for library files and how to point the IDE to a library located somewhere else? I know there are two general formats for the library file: #include <mylibrary.h> and #include "mylibrary.h" But I'm not sure when to use which.

How do I put a path (Apple OSX) in for a library, either relative or absolute? If relative, what's it relative too, the ArduinoSketchDirectory\library directory.

Because I use different computers with the IDE, I usually keep my sketches on a network drive (I use Jungle Disk). If my local Arduino sketch directory is something like C:\Users\scott\Documents\Arduino\ and my sketch is actually located s:\MySketches, does that make any difference with the libraries? Could I have libraries on my network drive?

1 Like

The proper place to put libraries is in a folder called "libraries" in the sketchbook directory.

On OSX, the default place for the Sketch book is:
/Users//Documents/Arduino/

So the default location for non-included sketches would be:
/Users//Documents/Arduino/libraries/

I think (but have not tested) that when compiling, the IDE will use the "Sketchbook" directory in Preferences to find the "libraries" folder.

You can put non-standard libraries in the Arduino application bundle too. However, each time you upgrade the Arduino IDE, you would lose them.
/Applications/Arduino.app/Contents/Resources/Java/libraries/

This is informative and I need the help. I am trying to install the wire library. Do I copy the whole folder named "wire" into the default location under the Arduino sketphad location? Or, do I take out the wire.h file from the folder, and copy it in to the sketchpad library directory that sits alone by itself?

It's weird, but it took ages to even find where the libraries are for the Mac. You can't download them from the Arduino site and you have to use a rather arcane, right click, show package command. I've never had to use that in all the years I've had a Mac.

Wire is included with the Arduino package, so I don't understand why you are trying to install it.

agilefalcon:
You can't download them from the Arduino site and you have to use a rather arcane, right click, show package command. I've never had to use that in all the years I've had a Mac.

Well, you shouldn't be changing the libraries inside the application bundle anyway. That's why you would use the "libraries" folder in Documents/Arduino.

I'm confused why you say you "can't download them". All of the built-in libraries are already built-in to the Application Bundle. Libraries that aren't included, are downloadable.

Sometimes I come across sketches with avr before the file name, like this:
#include <avr/pgmspace.h>
I found this example on PROGMEM - Arduino Reference

In this example, where would the Arduino IDE look for pgmspace.h?

Also, what's the difference between using " " verses < >?

Maybe this help