Arduino Forum

Forum 2005-2010 (read only) => Software => Troubleshooting => Topic started by: zzpza on Jul 23, 2008, 11:29 am

Title: AVR include directory
Post by: zzpza on Jul 23, 2008, 11:29 am
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 (<ARDUINO>/hardware/core/<CORE>/) and the avr include directory (<ARDUINO>/hardware/tools/avr/avr/include/), as well as any library directories (in <ARDUINO>/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 <ArduinoHome>/hardware/tools/avr/avr to /usr/avr/include/avr.

But it still doesn't work. Any ideas?

Thanks!
Title: Re: AVR include directory
Post by: mem on Jul 23, 2008, 11:38 am
Quote
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 <ArduinoHome>/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:
<ArduinoHome>/hardware/tools/avr/avr/include/avr

Title: Re: AVR include directory
Post by: zzpza on Jul 23, 2008, 01:34 pm
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]#


Title: Re: AVR include directory
Post by: zzpza on Jul 23, 2008, 05:34 pm
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:

[font=Courier New]find . -name io.h[/font]

Thanks!
Jules.
Title: Re: AVR include directory
Post by: mellis on Jul 23, 2008, 06:54 pm
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.  
Title: Re: AVR include directory
Post by: georgelstuart on Aug 09, 2008, 11:21 pm
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 (http://www.arduino.cc/playground/Learning/ArduinoSleepCode)
takes one to:
http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html
which links to:
http://www.nongnu.org/avr-libc/user-manual/sleep_8h.html
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
Title: Re: AVR include directory
Post by: Quijonsith on Aug 10, 2008, 07:37 am
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
Title: Re: AVR include directory
Post by: timstamp on Dec 22, 2009, 01:57 pm
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
Title: Re: AVR include directory
Post by: wayoda on Dec 23, 2009, 12:23 pm
Quote

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
Title: Re: AVR include directory
Post by: dwpelland@gmail.co on Feb 13, 2010, 09:59 pm
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
Title: Re: AVR include directory
Post by: vxir on Aug 06, 2010, 10:05 pm
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.  :-)