How to specify path for header files?
With gcc, how are you supposed to specify the path for header files?
This is what it's about: I've looked at a tutorial on SDL (Simple DirectMedia Layer) and the first thing that it suggests is to try a few lines of code to check that it can be initialized. (See below). Now in order to get it to find the SDL.h header file and to find functions like "SDL_Init", I had to specify the SDL library TWICE in the gcc command, once with the full path, and once with just the directory name. (I'm using Mandakelinux 10.1.)
$ gcc -isystem /usr/include/SDL -l SDL -o mytest mytest.c
I spent ages ploughing through the gcc manpage, and lots of trial and error before I stumbled onto that syntax. This is not what I want to find myself doing as a newbie. Is that actually the correct way to do it - should the gcc command line really have to be that complicated? Or am I missing something?
Here's the code, by the way.
#include <stdlib.h>
#include "SDL.h"
main(int argc, char *argv[])
{
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}
}
|