Help needed to run opengl programs in linux

Hi,

i am using redhat linux 9 and i am having some problems in running opengl programs in linux. I ran a sample program and i have got the following errors

 [root@localhost examples]# gcc -L/usr/lib -lGL -lGLU -lglut -lm -L/usr/X11R6/lib -lx11 lesson1.c -o lesson1

lesson1.c:9:61: GL/glut.h: No such file or directory
lesson1.c: In function main': lesson1.c:90: GLUT_RGBA’ undeclared (first use in this function)
lesson1.c:90: (Each undeclared identifier is reported only once
lesson1.c:90: for each function it appears in.)
lesson1.c:90: GLUT_DOUBLE' undeclared (first use in this function) lesson1.c:90: GLUT_ALPHA’ undeclared (first use in this function)
lesson1.c:90: `GLUT_DEPTH’ undeclared (first use in this function)

        i found glut installed in my system and the version is glut-3.7-12 and i can able to find the file libglut.so.3.7 in /usr/lib directory.

What else i have to install inorder to run opengl programs. Please give me a detailed explanation on how to obtain those packages and installing them since i am new to linux and opengl.

In my computer there is NO Graphics card installed .

If you suggest MESA 3d is my last option then please help me in installing those pacakages

    oss-opengl-glu-20000925-1.i386.rpm
    MesaLib-6.1.tar.gz 
    MesaDemos-6.1.tar.gz

thanks

Saravanan

You’ll need the glut-devel package aswell. In general, on Linux, header files are in the XXX-devel packages, and the run-time libraries are in XXX.

I had similar problems and finally got everything working. Check for the location of glut.h and make sure you have that in your library path. It does sound like you have glut installed, since the lib file is available. The definition errors are from not finding the header file. Include that in the compile line and ou should be set.

George

Originally posted by saravanan:
[b]Hi,

i am using redhat linux 9 and i am having some problems in running opengl programs in linux. I ran a sample program and i have got the following errors

 [root@localhost examples]# gcc -L/usr/lib -lGL -lGLU -lglut -lm -L/usr/X11R6/lib -lx11 lesson1.c -o lesson1

lesson1.c:9:61: GL/glut.h: No such file or directory
lesson1.c: In function main': lesson1.c:90:GLUT_RGBA’ undeclared (first use in this function)
lesson1.c:90: (Each undeclared identifier is reported only once
lesson1.c:90: for each function it appears in.)
lesson1.c:90: GLUT_DOUBLE' undeclared (first use in this function) lesson1.c:90:GLUT_ALPHA’ undeclared (first use in this function)
lesson1.c:90: `GLUT_DEPTH’ undeclared (first use in this function)

        i found glut installed in my system and the version is glut-3.7-12 and i can able to find the file libglut.so.3.7 in /usr/lib directory.

What else i have to install inorder to run opengl programs. Please give me a detailed explanation on how to obtain those packages and installing them since i am new to linux and opengl.

In my computer there is NO Graphics card installed .

If you suggest MESA 3d is my last option then please help me in installing those pacakages

    oss-opengl-glu-20000925-1.i386.rpm
    MesaLib-6.1.tar.gz 
    MesaDemos-6.1.tar.gz

thanks

Saravanan[/b]

the problem is that gcc does not find glut.h, because it is not in the default include path. you have to locate glut.h-

if it is, for example, in /usr/X11R6/include/GL

you have two options:

FIRST OPTION

#include <glut.h>

in the source file and

gcc -I/usr/X11R6/include/GL

when compiling. <-I> modifies the default include path.

SECOND OPTION

#include <GL/glut.h>

in the source code and

gcc -I/usr/X11R6/include

when compiling

<hope you see the difference…>

when nothing works, it is always good to use

gcc -c test.cc

this tells gcc only to compile, but not to link and create an executable. if gcc -c works without errors, you do not have syntax or include errors.

I use FreeBSD4.10 ,how do I compile “OpenGL program”?,how to I setup “FreeBSD enviroment”?
plz help me.

unto# gcc accum.c
/tmp/ccdJqsft.o: In function Init': /tmp/ccdJqsft.o(.text+0xf): undefined reference toglClearColor’
/tmp/ccdJqsft.o(.text+0x1f): undefined reference to glClearAccum' /tmp/ccdJqsft.o(.text+0x2c): undefined reference toglGenLists’
/tmp/ccdJqsft.o(.text+0x47): undefined reference to glNewList' /tmp/ccdJqsft.o(.text+0x5b): undefined reference toglColor3f’
/tmp/ccdJqsft.o(.text+0x82): undefined reference to glRectf' /tmp/ccdJqsft.o(.text+0x8a): undefined reference toglEndList’
/tmp/ccdJqsft.o(.text+0x94): undefined reference to glGenLists' /tmp/ccdJqsft.o(.text+0xaf): undefined reference toglNewList’
/tmp/ccdJqsft.o(.text+0xc3): undefined reference to glColor3f' /tmp/ccdJqsft.o(.text+0xe3): undefined reference toglRectf’
/tmp/ccdJqsft.o(.text+0xeb): undefined reference to glEndList' /tmp/ccdJqsft.o: In functionReshape’:
/tmp/ccdJqsft.o(.text+0x107): undefined reference to glViewport' /tmp/ccdJqsft.o(.text+0x117): undefined reference toglMatrixMode’
/tmp/ccdJqsft.o(.text+0x11f): undefined reference to glLoadIdentity' /tmp/ccdJqsft.o(.text+0x12c): undefined reference toglMatrixMode’
/tmp/ccdJqsft.o(.text+0x134): undefined reference to glLoadIdentity' /tmp/ccdJqsft.o: In functionKey’:
/tmp/ccdJqsft.o(.text+0x176): undefined reference to glPolygonMode' /tmp/ccdJqsft.o(.text+0x17e): undefined reference toglutPostRedisplay’
/tmp/ccdJqsft.o(.text+0x192): undefined reference to glPolygonMode' /tmp/ccdJqsft.o(.text+0x19a): undefined reference toglutPostRedisplay’
/tmp/ccdJqsft.o: In function Draw': /tmp/ccdJqsft.o(.text+0x1bb): undefined reference toglPushMatrix’
/tmp/ccdJqsft.o(.text+0x1e0): undefined reference to glScalef' /tmp/ccdJqsft.o(.text+0x1f0): undefined reference toglClear’
/tmp/ccdJqsft.o(.text+0x201): undefined reference to glCallList' /tmp/ccdJqsft.o(.text+0x21d): undefined reference toglAccum’
/tmp/ccdJqsft.o(.text+0x22d): undefined reference to glClear' /tmp/ccdJqsft.o(.text+0x23e): undefined reference toglCallList’
/tmp/ccdJqsft.o(.text+0x25a): undefined reference to glAccum' /tmp/ccdJqsft.o(.text+0x26f): undefined reference toglAccum’
/tmp/ccdJqsft.o(.text+0x277): undefined reference to glPopMatrix' /tmp/ccdJqsft.o(.text+0x285): undefined reference toglutSwapBuffers’
/tmp/ccdJqsft.o(.text+0x28d): undefined reference to glFlush' /tmp/ccdJqsft.o: In functionmain’:
/tmp/ccdJqsft.o(.text+0x33a): undefined reference to glutInit' /tmp/ccdJqsft.o(.text+0x374): undefined reference toglutInitDisplayMode’
/tmp/ccdJqsft.o(.text+0x389): undefined reference to glutInitWindowSize' /tmp/ccdJqsft.o(.text+0x399): undefined reference toglutCreateWindow’
/tmp/ccdJqsft.o(.text+0x3ae): undefined reference to glutReshapeFunc' /tmp/ccdJqsft.o(.text+0x3be): undefined reference toglutKeyboardFunc’
/tmp/ccdJqsft.o(.text+0x3ce): undefined reference to glutDisplayFunc' /tmp/ccdJqsft.o(.text+0x3d6): undefined reference toglutMainLoop’

how do I set library path? hlep~plz

you have to tell gcc which libraries to use:

  1. find the libraries you need. for example /usr/lib/libGL.so.1 and /usr/lib/libGLU.so.1

  2. if gcc in freebsd is the same as in linux- use -L to set the include path and -l to choose the libraries:

gcc -L/usr/lib accum.c -lGL -lGLU

Upper floor,
Thanks you help , Really

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