Need help compiling (beginner help!)

Okay, ive spent all day setting up Debian. I know a lot about computers, but nearly nothing about linux.

I installed the most recent xserver-xfree86 software, and set up a KDE windows manager.

I downloaded NEHE’s first tutorial for linux, and tried to compile it, and gcc cant find

GL/glut.h
GL/gl.h
GL/glu.h

i know theres somthign simple i can do, but i have no idea what. how can i get gcc to find these files? theyre supposed to come installed right? i apt-get install mesademos to get glut, but it still doesnt find htat.

code-

#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
… etc (havnt even got to this part yet :slight_smile: )

Thanks!

oliver

ok, this is noob to noob

no guarantees :slight_smile:

make sure you have all the “developer” stuff installed during your initial setup

open the file in the editor of your choice

(I’m on Fedora and I use Kate)

on the command line do the following

gcc -o test name_of_file.c -lglut

hope that helps

oops :slight_smile:

make sure you check that you have glut on your system

somelse mentioned that glut 3.7-8 is the one to get

glut.h usually lives at /usr/include/GL

and libglut at /usr/lib

cheers

Did the error say that the header files were not found, or that the functions you used were “undefined.” They are 2 very different errors.

If you don’t have the GL headers in /usr/include/GL, you might have them someplace like /usr/X11R6/include/GL, and if that is the case, you may need to include -I/usr/X11R6/include on the command line…

The next problem that you will likely run into is linker errors caused by not specifying the libraries you need to link. You do that by using the -l option. If the library is named libGL.so, the -l option looks like -lGL. So for OpenGL libraries, you generally need -lGL -lGLU, and -lglut if you are using glut.

Again, the GL libraries might be found in /usr/X11R6/lib if they aren’t in /usr/lib. If that is the case you may need to add -L/usr/X11R6/lib.

Sometimes you may get undefined errors to other X functions, and will need to include those libraries as well. (-lXi and -lXmu are commonly needed). One way I use to check what library a function is in, is by executing the following:

grep functionName /usr/lib/*

or

grep functionName /usr/X11R6/lib/*

So, in summary, you may end up having a command line that looks like so:
gcc -o myprog myprog.c -I/usr/X11R6/include -L/usr/X11R6/lib -lGL -lGLU -lglut -lXi -lXmu

you should simply check manually if these files are present… located at /usr/include/GL/… if they are, fine, if not, install them. OpenGL header files can be found at

http://oss.sgi.com/projects/ogl-sample/registry/

Jan

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.