PDA

View Full Version : Glut in Linux



nspm
10-10-2002, 10:12 AM
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

nexusone
10-10-2002, 11:35 AM
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:
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

jmg
10-10-2002, 11:44 AM
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.

nspm
10-10-2002, 11:51 AM
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

10-11-2002, 04:01 AM
Find the location of libGLUT.so and tell gcc about it with the -L flag. For example -L/usr/X11R6/lib

10-11-2002, 04:03 AM
Originally posted by jmg:
*snip*
you may need to tell it -L/usr/X11R6/include.[/B]

I believe that L should be an I?

jmg
10-12-2002, 08:35 AM
> 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).]

KShots
10-15-2002, 04:24 PM
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 to `glShadeModel'
/tmp/ccncR0l9.o(.text+0xfc): undefined reference to `glMaterialfv'
/tmp/ccncR0l9.o(.text+0x115): undefined reference to `glMaterialfv'
/tmp/ccncR0l9.o(.text+0x12e): undefined reference to `glLightfv'
/tmp/ccncR0l9.o(.text+0x147): undefined reference to `glLightfv'
/tmp/ccncR0l9.o(.text+0x160): undefined reference to `glLightfv'
/tmp/ccncR0l9.o(.text+0x174): undefined reference to `glLightModelfv'
/tmp/ccncR0l9.o(.text+0x184): undefined reference to `glEnable'
/tmp/ccncR0l9.o(.text+0x194): undefined reference to `glEnable'

...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).]

cthulhu666
10-16-2002, 12:04 AM
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!

jmg
10-16-2002, 05:54 AM
> 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

KShots
10-16-2002, 03:06 PM
Thanks, that fixed my problem http://www.opengl.org/discussion_boards/ubb/smile.gif Just not used to developing in Linux (Was using Microsoft's Visual C++). Anyways, program compiled and ran. Thx guys http://www.opengl.org/discussion_boards/ubb/smile.gif