Glut in Linux

Hi,

I would like to know how do I compile programs with (#include <GL/glut.h> ), i receive an error answer like cannot find glut.h , so i’m asking to someone help me with this (when i installed redhat 7.3 I select to install glut package)? I compiled with gcc (gcc -o outputfile Bounce.c)

Thank U

Check the include directory, see if it is in the “include” or in “include\GL” directory.

#include<glut.h> try this:

Originally posted by nspm:
[b]Hi,

I would like to know how do I compile programs with (#include <GL/glut.h> ), i receive an error answer like cannot find glut.h , so i’m asking to someone help me with this (when i installed redhat 7.3 I select to install glut package)? I compiled with gcc (gcc -o outputfile Bounce.c)

Thank U[/b]

Make sure you have glut.h in /usr/X11R6/include/GL.

If it’s there and you’re still getting the same error, then (when you run gcc/g++) you may need to tell it -L/usr/X11R6/include.

hi thanks for your reply now i receive an error message like this “/tmp/cc0whPY9.o(.text+0x301): undefined reference to `glutMainLoop’” and others like that .

Thank U

Find the location of libGLUT.so and tell gcc about it with the -L flag. For example -L/usr/X11R6/lib

Originally posted by jmg:
snip
you may need to tell it -L/usr/X11R6/include.[/b]

I believe that L should be an I?

> I believe that L should be an I?

Doh! Yes, of course. Sorry.

To explicitly tell gcc/g++ where to find your GL libs:
-L/usr/X11R6/lib

To explicitly tell gcc/g++ where to find your GL headers:
-I/usr/X11R6/include/GL

Note though that gcc may automatically look in those locations for libraries and headers, and also note that, depending on your linux distibution, there may be symbolic links in /usr/include and /usr/lib to the relevant files in /usr/X11R6.

Thanks for the correction johane.

[This message has been edited by jmg (edited 10-12-2002).]

I’m having similar problems…

I have instead of libGLUT.so it’s libglut.so (lowercase)… any probs there?

My errors during compile after the -I and -L including paths leading to the .h and .so files include:

The line I used to generate this:

/tmp/ccncR0l9.o(.text+0xd3): undefined reference to glClearColor' /tmp/ccncR0l9.o(.text+0xe3): undefined reference toglShadeModel’
/tmp/ccncR0l9.o(.text+0xfc): undefined reference to glMaterialfv' /tmp/ccncR0l9.o(.text+0x115): undefined reference toglMaterialfv’
/tmp/ccncR0l9.o(.text+0x12e): undefined reference to glLightfv' /tmp/ccncR0l9.o(.text+0x147): undefined reference toglLightfv’
/tmp/ccncR0l9.o(.text+0x160): undefined reference to glLightfv' /tmp/ccncR0l9.o(.text+0x174): undefined reference toglLightModelfv’
/tmp/ccncR0l9.o(.text+0x184): undefined reference to glEnable' /tmp/ccncR0l9.o(.text+0x194): undefined reference toglEnable’

…and they go on for quite a while. Any ideas?

g++ -I/usr/X11R6/include -L/usr/X11R6/lib -o Warfare main.cpp

[This message has been edited by KShots (edited 10-15-2002).]

My best guess would be that you need to tell the compiler to link to those libraries:

Try adding this to your compile statement: -lGL -lglut

Good luck!

> I have instead of libGLUT.so it’s libglut.so (lowercase)… any probs there?

No, libglut.so is correct.

Btw, the errors you’re seeing are linker errors, not compiler errors (since, as you can see, ccncR0l9.o has evidently already been built. The linker simply can’t resolve references to the functions in libGL.so).

Typical command is

g++ main.cpp -o Warfare -I/usr/X11R6/include -L/usr/X11R6/lib -lglut -lGLU -lGL

Thanks, that fixed my problem Just not used to developing in Linux (Was using Microsoft’s Visual C++). Anyways, program compiled and ran. Thx guys