Compiling with gcc

Hello, I am trying to compile the first sample program from the redbook. Located in the programming guide link.

It has these 2 include statements.

#include <GL/gl.h>
#include <GL/glut.h>

I try to compile with this command: (Note I am using slackware 10.1)

gcc -lGLUT -lGL -o sample sample.c

Is anything wrong with this?
I get this error:

/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/…/…/…/…/i486-slackware-linux/bin/ld: cannot find -lGLUT
collect2: ld returned 1 exit status

I have GLUT 3.7. Infact it comes with slackware 10.1. How nice! But I dont know how to use it yet.
Any help would be appreciated.

Beezer

you have to specify a “library path”, look where is libglut.so on your system [I put my one into /usr/local/lib ] and supply the library path to gcc:
in my case: gcc mycrap.c -L/usr/local/lib -L/some/other/lib/path -lglut -lother

and be careful about case-sensitivity: libGLUT, libglut, libGlut are three different names!

In fact the good command is :
gcc arbfplight.c -o arbfplight -L/usr/X11R6/lib/ -lGL -lGLU -lglut

Be careful ! GLUT is not the same thing as glut.

I try “gcc hello.c -o hello -L/usr/X11R6/lib/ -lGL -lGLU -lglut”, all good, realy work ! (I work in Slackware)

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