I'm trying to #include some files, e.g. avr/io.h or avr/interrupt.h but the compiler can't find them. From the Arduino documentation it says:
"The include path includes the sketch's directory, the target directory (/hardware/core//) and the avr include directory (/hardware/tools/avr/avr/include/), as well as any library directories (in /hardware/libraries/) which contain a header file which is included by the main sketch file."
So I've found the files I want to include, they are in (on Linux) /usr/avr/include/avr/ so I tried doing a softlink from /hardware/tools/avr/avr to /usr/avr/include/avr.
So I've found the files I want to include, they are in (on Linux) /usr/avr/include/avr/ so I tried doing a softlink from /hardware/tools/avr/avr to /usr/avr/include/avr.
I don't know if that was just a typo in the post but I think they should be in:
/hardware/tools/avr/avr/include/avr
What distribution are you on? How did you install avr-gcc? In theory, avr-gcc should be able to find its own include files in their default location, regardless of your working path.
Folks,
I am having trouble including libraries too, but with (i think) a different problem.
Specifically, I am trying to experiment with sleep modes, but the examples specify #include <avr/sleep.h> without any link to the actual library to include.
the link from the arduino.cc sleep example (Arduino Playground - ArduinoSleepCode)
takes one to: avr-libc: <avr/sleep.h>: Power Management and Sleep Modes
which links to: avr-libc: sleep.h File Reference
which is an HTML page with explanations of various details about AVRs and sleep modes, but for the life of me, I can't find a link to or a copy of an actual library that I can put in my libraries folder and use.
In a larger sense, I am having this problem with other libraries too, I see some code or example code that someone has posted, and they use #include statements for libraries that are not part of the default Arduino IDE, and no link to the library, no library enclosure linked for download, etc. Is it just me? Is there some repository of libraries that everyone else somehow knows about, or am I missing something?
zzpza:
Is your code "#include avr/io.h" or "#include io.h"? I would think that if the environment sets the avr directory as a default location, then telling to check the avr directory would return as the file not being there. I don't know if this is the case, but worth a try.
I had the same problem and it was drivin me crazy. Then, for some reason I removed the spaces before and after the pathnames, ie instead of #include < avr/io.h > I tried #include <avr.io.h> and the problem went away! I hope this helps
danno
Just to fill out an old thread with another answer:
If you are doing this in a file that is NOT your main one, then add the same #include to your main file (the one with loop in it). Amazingly the include file suddenly is found in all files. Total guess but I think that the Arduino IDE is trying to be helpful by scanning your sketch and automatically adding -I lines to the compile. But its not doing so for all .c and .h in your sketch so it ends up outsmarting itself and confusing mere mortals like you and I.