Problem with 'include'


First of all I’ll say that I’m not that not really a programmer (but a mechanical engineer) and I’m on a linux machine here (but that doesn’t matter for my problem I guess).

Anyway, I want to include SDL in a project to make a nice gui and stuff. But the problem is that the SDL.h is in a folder called SDL in my /usr/include folder. I can load any library in the include folder, but when it has it separate folder (like sdl) it says “error: SDL.h: No such file or directory”.

I tried:
#include <SDL.h>
#include “SDL.h”
#include “SDL/SDL.h”
#include “./SDL/SDL.h”

but non of the above work. So my question is how do I include this in my project? (I also have no idea what the difference between “” and <> is, so I tried both).

I’m guessing this is something really stupid, but I just don’t know how to do it.
Any help please.


include "/usr/include/SDL/SDL.h" seems to work, but I'd rather not do it with an absolute path so it can also be used on other platforms

#include <SDL/SDL.h>

The <> brackets are for system includes, “” quotes for local includes to the current source directory. In both cases the string is a pathname relative to the appropriate directory. Here you need <> and relative to the system library directory the file is SDL/SDL.h

Also you say /usr/include - I presume you mean /usr/lib/avr/include or wherever the avr-gcc include files live on your system (the same place avr/iom328p.h lives, for instance - the AVR cross-compiler system is entirely separate from your computers native C compiler.)

Hang on, are you actually asking about Arduino programming at all?

#include <SDL.h> is the right one, but when compiling you have to tell GCC to add the SDL directory to the include path on the command line. The easiest way is with pkg-config:

gcc -o prog prog.c pkg-config sdl --cflags --libs (note the backquotes, they are important)