tags:

views:

1114

answers:

2

I have a C-code which I have not managed to run http://dl.getdropbox.com/u/175564/problem-sdl.png

The problem is in OpenGL or SDL. I do not have SDL.h at /usr/local/SDL/SDL.h, so gcc cannot find it.

I have SDL.h installed by MacPorts at /opt/local/include/SDL/SDL.h.

I tried to copy it to /Masi/local/SDL/SDL.h unsuccessfully at the folder by

cp /opt/local/include/SDL/SDL.h /

and by

cp /opt/local/include/SDL/SDL.h /Masi/local/SDL/

I tried to solve the problem by creationg a symlink by

$ln -s /opt/local/include/SDL/SDL.h /Masi/local/SDL/SDL.h
+2  A: 

No, Ubuntu does not have them by default (at least the development versions). For my own little program I just installed libsdl1.2-dev and mesa-common-dev (OpenGL).

For the build process I use scons which produces the following commands:

gcc -o src/geom.o -c -Wall -ansi src/geom.c
gcc -o src/main.o -c -Wall -ansi src/main.c
gcc -o test src/main.o src/geom.o -lSDL -lGL

If you install the libraries in some non-standard location, you might have to specify your own include (-I) and library (-L) paths.

Thank you for the piece of information! I had them in my Ubuntu. The problem seems to be elsewhere.
Masi
The problem is obviously that gcc cannot find SDL.h. Do you have it in /usr/local/SDL/SDL.h? Do you include it like so: #include <SDL/SDL.h> ?
+4  A: 

the simplest way to get all the compiler flags for SDL is by using sdl-config:

gcc sdl_gl_1.c $(sdl-config --cflags --libs) -lGL -lGLU
d0k
I get the following error: $gcc sdl_gl_1.c $(sdl-config --cflags --libs) -lGL -lGLUld: library not found for -lGLcollect2: ld returned 1 exit status
Masi
libGL is the OpenGL library. It is usually installed with your graphics card drivers.
d0k