Questions about #include statements in sketches

I’ve had my ATmega 2560 for some time, and experimented with the Robot Power MegaMoto shield. I made lots of mistakes, but I learned from them.

I’m using the newest Arduino IDE version 1.0 on an ubuntu machine. I have it located in a folder in my Public directory. I know a few things about Linux/Ubuntu, but I’m not sure that’s the correct place for it. And the Arduino libraries are there too.

However I discovered the libraries are also at /usr/include/arduino/libraries/ . Maybe this is left over from the previous install of Arduino 0022 (or whatever it used to be) Is my new Arduino IDE version 1.0 looking at that location? or at the libraries unpacked and located in my Public folder?

I wouldn’t have discovered all of the above except I now have the Circuits@Home USB Host Shield. I’ve downloaded the Library for it, which includes a folder of Examples. Many of these example sketches (they have .pde extensions) have #include <something.h> directives in them.

I did some googling and learned that the carets around the file name indicate that the file is “somewhere else”. I can’t find any sort of Setup or Preference that explicitly defines where “somewhere else” is.

The demo sketches included in the Examples for the USB Host Shield library throw all sorts of errors when I try to Verify them.
mainly “file does not exist” regarding all those #include <???.h> lines.

I tried copying all the named files to the folder containing the sketch, and changing the lines to read #include “???.h”, which as I understand it, tells the compiler to look in the “local directory”.

That’s a lot of work, and I’m sure it’s NOT the best way. However, doing this seems to get rid of the “file does not exist” errors. The sketch seems to verify/compile, but I still can’t get it to upload to my Arduino/shield combo.

I’m in that “how do I figure out what question to ask” stage with this, please bear with me and if you can offer some insight, thanks!

http://arduino.cc/forum/index.php/topic,88380.msg664107.html#msg664107

The above linked message seems to be an authoritative answer to one of my questions.

The poster says libraries (and from context I gather he means "non-standard" libraries, like the USB-2.0 library) should go in a subfolder of the sketches directory. In my case that's /home//sketchbook/

I'm going to try that, creating a /libraries/ subfolder and placing the USB 2.0 library there.

Why is this all so "not specified"? :0 Why must one dig, dig, dig for "opinions" in the forums, instead of being able to just read "the straight skinny" from the Arduino Reference???

I don't know if I would trust everything that guy says. He certainly isn't authoritative. ;)

dkathrens77: Why is this all so "not specified"? :0 Why must one dig, dig, dig for "opinions" in the forums, instead of being able to just read "the straight skinny" from the Arduino Reference???

That's the nature of open source projects I guess.

This page might help, even though it is out of date: http://arduino.cc/en/Hacking/BuildProcess

Thanks James, you are correct about the libraries subfolder in sketches. After I tried it, shazam! Sketches compile and upload.

And embarrassingly enough, I find that your statements are echoed in the "official" Arduino Reference.

This from the reference/libraries page:

Contributed Libraries

If you're using one of these libraries, you need to install it first. To do so, download the library and unzip it. It should be in a folder of its own, and will typically contain at least two files, one with a .h suffix and one with a .cpp suffix. Open your Arduino sketchbook folder. If there is already a folder there called libraries, place the library folder in there. If not, create a folder called libraries in the sketchbook folder, and drop the library folder in there. Then re-start the Arduino programming environment, and you should see your new library in the Sketch > Import Library menu.

I think I MAY be past that very steep part of the learning curve I think of as "the hair pulling stage".

dkathrens77: Why is this all so "not specified"? :0 Why must one dig, dig, dig for "opinions" in the forums, instead of being able to just read "the straight skinny" from the Arduino Reference???

Something like this maybe, under the heading "Contributed Libraries"?