# Problems compiling code using SDL 1.2



## killerklown (Nov 2, 2011)

Hi there, deamons!

I've just installed sdl with the command [cmd=]portmaster devel/sdl12[/cmd]T hen I wrote a little code to test if everything went ok:


```
#include "SDL/SDL.h"
int main( int argc, char* args[] )
{
    SDL SDL_Init( SDL_INIT_EVERYTHING );
    SDL SDL_Quit();
    return 0;
}
```

and I compiled it: [cmd=]g++ -o test test.cpp -lSDL[/cmd] but I get that error message:

```
test.cpp:1.21:error: SDL/SDL.h: No such file or directory
prova.cpp: In function 'int main(int, char**)':
prova.cpp:5: error: 'SDL_INIT_EVERYTHING' was not declared in this scope
prova.cpp:5: error: 'SDL_Init' was not declared in this scope
prova.cpp:7: error: 'SDL_Quit' was not declared in this scope
```

So... why can't g++ see sdl libs if they are in /usr/local/include/SDL/? (checked with find command)
How can I solve that annoying problem? Thanks in advance!


----------



## falkman (Nov 2, 2011)

On FreeBSD /usr/local/include is not in the default include path [nor is /usr/local/lib for libs].

Use the following to build it:

[CMD=]g++ -I/usr/local/include -L/usr/local/lib -o test test.cpp -lSDL[/CMD]

[CMD=](Note the capital I and capital L, not lowercase)[/CMD]

This will add /usr/local/include to the include paths to search, and /usr/local/lib to the lib paths to search. I'm assuming that if SDL puts includes in /usr/local, that libs will end up there too... if not, you won't need the _-L/usr/local/include_ argument.

Regards,
Brandon Falk


----------



## killerklown (Nov 4, 2011)

It worked perfectly! Thank you so much!


----------

