Atmel Studio 6.2 Include File Referencing

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have had problems getting headers referenced in multi-library projects before.

 

But this time it was weird, in that the Output Error message insisted the Adafruit_ILI9341.h  reference to:

#include "Adafruit_GFX.h"

was referring to a file that did not exist.

 

Tried all the usual things - toolchain referencing & project build order, but nothing.

In the end I copied the Adafruit_GFX.h into the folder of the application project and the solution built fine.

 

Maybe not surprising, but then I deleted the header and the solution still built.

 

So now it's fixed, but am not sure what happened; either why the error ocurred in the first place, or especially why it went away.

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Include files seem to bite a lot of people. It's fairly simple really. For GCC (but actually for almost all other compilers too) the compiler accepts a -I (that's a capital "eye") command line switch, several in fact and each says "by the way, when you hit #include this is another place I want you to look". So your .h files can actually be anywhere on the disk you liked such as:

C:.
|
+---Project
|   |
|   \---src
|           main.c
|           init.c
\---lib
    |   uart.c
    |
    \---headers
        |
        \uart        
            uart.h

So now main.c can just:

#include <avr/io.h>
#include "uart.h"

int main(void) {
    uart_something();
}

And as long as you pass

-I\lib\headers\uart

to the compiler the uart.h can be found - the #include itself knows nothing about the location. You may not want to include the '\' at the very start of that (absolute path) but might choose, instead to use: 

-I..\..\lib\headers\uart

to achieve the same but with the library headers relative to the project files.

 

In Studio 6 the project configuration has a "Directories" section for the pre-processor. Each directory you add there will be passed as a -I to the compiler when you build.

Last Edited: Thu. Jan 8, 2015 - 04:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the info.

 

For Atmel Studio I've only every used the 'Directories' section to point to the headers, and it had always worked.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and it had always worked.

So what was/is the issue here? You said you had an issue with .h file location and we both know that "Directories" is the solution.