How things are organized

I'm pretty new to the Arduino party, but I guess everyone had to start somewhere. I've been fiddling around reading books for a while but until I got serious about an Arduino-based project I've not been motivated to actually dig in. So far I'm having fun and it's coming along well but while tutorials and the various websites are great, sometimes you just need to ask a question... So here's mine:

How does the Arduino IDE expect things to be organized? I have created a Sketchbook but am not sure where things like Libraries that I want to add should go. For example, the IDE installed itself in the /Program Files (x86) directory and that's where the Libraries folder is located. I've played with some Examples using these libraries, no problem.

But my project uses the Teensy, so I have added those extensions in, and when I select Teensy I see a lot more libraries than otherwise. There's also a Libraries folder in my Sketchbook location (i.e. /Documents/Arduino/Libraries and when I've downloaded some Libraries, this is where they ended up.

Finally I've downloaded an entire project done by someone else (e.g. /Documents/something_master.zip) that includes a folder with the .ino file in it, another folder called Libraries with some libraries in it, and a bunch of .h and .cpp and other files in the main (master) folder. So this makes three places called "Libraries".

When I try to compile the .ino file I got an error that it couldn't find one .h file. I've copied the entire project folder into my Sketchbook, but the same error occurs even though I can look in the folder and see the .h file it wants is present. Thus I think I've violated some rule(s) about how things should be organized.

It would be most helpful to me if someone could take a moment and just explain in words how the Arduino IDE expects to find things. I know from looking at the compiler verbose messages that I've got multiple copies of some libraries but it seems to be OK with picking and using one of them.

Should there be only one place where Libraries exist, and if so, which of the above should it be? And if you want to start with a complete project that already has been put into a package (e.g. on Github) - how do you add or integrate in with the IDE and libraries you already have?

I've gone through several tutorials and understand how to add Zip libraries and all but I'd like to know if I've made a mess of it and just need to zap everything and start from scratch, or if by moving some stuff around I can make the compiler happy. I suspect I've made it harder than it should be!

Thanks, Bob

1 Like

w9ran:
For example, the IDE installed itself in the /Program Files (x86) directory and that's where the Libraries folder is located.

You should treat that libraries folder as off limits. The IDE will update / remove files in that folder without your permission.

There's also a Libraries folder in my Sketchbook location (i.e. /Documents/Arduino/Libraries and when I've downloaded some Libraries, this is where they ended up.

That folder belongs to you. As far as I know, the IDE will only install / update / remove files in that folder with your permission.

Finally I've downloaded an entire project done by someone else (e.g. /Documents/something_master.zip) that includes a folder with the .ino file in it, another folder called Libraries with some libraries in it, and a bunch of .h and .cpp and other files in the main (master) folder.

The main (master) folder belong in Sketchbook under a subdirectory with the same name as the dot-ino file. The contents of the libraries folder belong in Sketchbook\libraries under a subdirectory with the same name as the primary include file (the library name).

1 Like

The stuff in /Program Files (x86) is managed by the IDE and should not be touched.

Your sketchbook contains one directory per sketch. The main .ino file for the sketch has the same name as the directory it is in.

The sketchbook contains a 'libraries' directyory that contains one directory per library. Try to use Sketch->Include Library->Manage Libraries... to add third-party libraries because the IDE can then check for available updates. If the library you need is not available through the library manager you can manually create a library directory.

The sketchbook contains a 'hardware' directory. Third-party cores get installed there. Use Tools->Board->Board Manager... when possible. I've never quite figured out how to install third-party cores manually.

1 Like

Very helpful, just what I needed! Thanks, I'll get things cleaned up.

Bob

1 Like