compiling problem

HI, i’m new to openGL.
I have a slackware 8.0 and installed the GLUT library, but i don’t have Mesa (where can i find it? is it necessary to use GLUT or not?).

I tryed to compile a program i found on the glut.column1.ps file i downloaded on opengl.org web page, and i get the followng errors:

bash-2.05$ make
gcc -c -o prova.o prova.c
gcc -o es prova.o -L/usr/X11R6/lib -L/home/galy/GLUT/glut-3.7/lib/glut -lX11 -lm -lGL -lGLU -lglut
/home/galy/GLUT/glut-3.7/lib/glut/libglut.so: undefined reference to XGetExtensionVersion' /home/galy/GLUT/glut-3.7/lib/glut/libglut.so: undefined reference to XFreeDeviceList’
/home/galy/GLUT/glut-3.7/lib/glut/libglut.so: undefined reference to XQueryDeviceState' /home/galy/GLUT/glut-3.7/lib/glut/libglut.so: undefined reference to XListInputDevices’
/home/galy/GLUT/glut-3.7/lib/glut/libglut.so: undefined reference to XFreeDeviceState' /home/galy/GLUT/glut-3.7/lib/glut/libglut.so: undefined reference to XOpenDevice’
/home/galy/GLUT/glut-3.7/lib/glut/libglut.so: undefined reference to XmuLookupStandardColormap' /home/galy/GLUT/glut-3.7/lib/glut/libglut.so: undefined reference to XSelectExtensionEvent’

Bye
p.s. do i need to include X11?

Mesas homepage is at http://mesa3d.org/ but it is also included in all distributions. You already have an OpenGL library installed so you do not need Mesa. If you have a NVidia card should you use drivers from their page if not is your installed Mesa library OK.
You are missing -lXmu at your command line needed by the XmuLookupStandardColormap function. The others missing functions is in -lX11. Try to move -lglut before -lX11. Your order works for me but I can not come up with any other suggestion.
You do not have to include X11 in your GLUT programs since GLUT takes care of that.

Hi, I installed Mesa and now the compilation works fine.
I only don’t understand why…

Bye

Mesa includes GLUT but this version is easier to use because you do not need the X-libraries on the command line. You should now be able to build your program with
gcc -c -o prova.o prova.c
gcc -o es prova.o -lm -lGL -lGLU -lglut

The disadvantage is that you may have overwritten some library and no longer have direct rendering. This can be tested with the glxinfo command.

You always want -lX11 after your opengl stuff. Opengl is built on X11, and the linker resolves left to right.

Sometimes you also have to add -lXext since not all the X functions are in libX11

GLUT in the Mesa distribution is built in such a way that you do not need -lX11 on the command line. The safe order in the command line is to have the higher levels library before the lower levels libraries that they depend on. The explanation is written here http://users.actcom.co.il/~choo/lupg/tutorials/libraries/unix-c-libraries.html#link_order

You only have to type
g++ program.c -o program name -lglut -lm
-lGL -lGLU
if you type more you will have errors if you type less you will have errors, you may use gcc

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