AVR include directory

Hi,

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.

But it still doesn't work. Any ideas?

Thanks!

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

nope, that doesn't work either. :-/

22: error: avr/io.h : No such file or directory In function 'void setup()':

[root@wintermute arduino-0010]# ls -l hardware/tools/avr/avr/include/avr/io.h
-rw-r--r-- 1 root root 11499 2007-07-18 10:04 hardware/tools/avr/avr/include/avr/io.h
[root@wintermute arduino-0010]#

Can someone with a working IDE running on Linux please run a command for me and post the outcome?

Can you change to your arduino directory (the one where you can see examples, hardware, lib, etc), and run the following:

find . -name io.h

Thanks!
Jules.

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?

any help is appreciated.
thanks

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.

-Jon

Hi all,

I've just encountered a problem similar to this (on my fresh install of Debian 5/Lenny) and fixed it by installing the following:

gcc
gcc-avr
avr-libc
avrprog
avrdude

Some of those probably don't need to be installed but I just installed the lot and it seems to work.

Regards,
Tim

I've just encountered a problem similar to this (on my fresh install of Debian 5/Lenny) and fixed it by installing the following:

gcc
gcc-avr
avr-libc
avrprog
avrdude

Some of those probably don't need to be installed but I just installed the lot and it seems to work.

You don't need avrprog, but all the others must be installed to run the IDE on Linux
Eberhard

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 :wink:
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. :slight_smile: