PDA

View Full Version : Noob question about OpenGL compilation in Linux



D1G1T4LL
12-04-2003, 03:36 PM
Hello all,
can anybody help me with the following problem ? I just bought a book on OpenGL coding under Gnu C. I'm trieing for over a week to make it work. I've installed the newest glut, glut 3.7.6 and still it doesnt work.

according to the book I should compile like this :

cc simple.c -o simple -lGL -lGLU -lX11 -lm -L/usr/lib

but then I get the following Error message :
Cannot find -lglut, can anybody explain to me what this lglut is and where I can find it ?

john
12-04-2003, 04:09 PM
cc simple.c -o simple -lGL -lGLU -lX11 -lm -L/usr/lib
but then I get the following Error message :
Cannot find -lglut, can anybody explain to me what this lglut is and where I can find it ?

well, that's strange that you get the error about glut, since your command line doesn't include it :-) I think the command you typed must have had '-lglut' somewhere, right?

-l<something> means you want to link <something> with your project. The linker is saying that it can't find the glut library. What you need to do is give the linker the path to find libglut.a (or libglut.so, or libglut.someversion....). My glut is installed in /usr/X11R6/lib, so I'd add the command '-L/usr/X11R6/lib' to my command line (without the "'").

gcc simple.c -o simple -lGL -lGLU -lglut -lX11 -lm -L/usr/lib -L/usr/X11R6/lib

btw, the -o indidcates the executable to build (so, if you had '-o foobar' then the compiler would compile simple.c to the executable foobar). -lm means to include the maths library, -lX11 is the (or, one of) the X libraries, and -GL and -lGLU are the OpenGL and OpenGL utilities libraries respectively

cheers,
John

idr
12-05-2003, 06:58 AM
You need to have the glut and glut-devel packages installed. I believe that newer versions of Redhat have stopped including those packages, so you'll have to get the source and build your own. There's another thread in this forum about that.

D1G1T4LL
12-05-2003, 11:13 AM
thanks for answering, I now got my first Polygon running, even rotating and with colors. At first I still couldn't get it to work, but when I took one of the redbook examples that was with glut, rewrote the code in in, with the example of the book, that was what finally worked.

Finally, running OpenGL code, I wrote myself I've waited years to see this.