Linux Fedora Core 1 - Undefined References???

My glut libraries are in what uh…
/usr/include/GL/fileheadernamehere.h
I receive the following errors compiling the first tutorial linux code from http://nehe.gamedev.net

[root@localhost kane]# gcc lesson1.c
In file included from lesson1.c:9:
/usr/include/GL/glut.h:19:1: warning: “APIENTRY” redefined
In file included from /usr/include/GL/glut.h:14,
from lesson1.c:9:
/usr/include/GL/gl.h:99:1: warning: this is the location of the previous definition
/tmp/ccYKzhrU.o(.text+0x1f): In function InitGL': : undefined reference to glClearColor’
/tmp/ccYKzhrU.o(.text+0x36): In function InitGL': : undefined reference to glClearDepth’
/tmp/ccYKzhrU.o(.text+0x46): In function InitGL': : undefined reference to glDepthFunc’
/tmp/ccYKzhrU.o(.text+0x56): In function InitGL': : undefined reference to glEnable’
/tmp/ccYKzhrU.o(.text+0x66): In function InitGL': : undefined reference to glShadeModel’
/tmp/ccYKzhrU.o(.text+0x76): In function InitGL': : undefined reference to glMatrixMode’
/tmp/ccYKzhrU.o(.text+0x7e): In function InitGL': : undefined reference to glLoadIdentity’
/tmp/ccYKzhrU.o(.text+0xb6): In function InitGL': : undefined reference to gluPerspective’
/tmp/ccYKzhrU.o(.text+0xc6): In function InitGL': : undefined reference to glMatrixMode’
/tmp/ccYKzhrU.o(.text+0xed): In function ReSizeGLScene': : undefined reference to glViewport’
/tmp/ccYKzhrU.o(.text+0xfd): In function ReSizeGLScene': : undefined reference to glMatrixMode’
/tmp/ccYKzhrU.o(.text+0x105): In function ReSizeGLScene': : undefined reference to glLoadIdentity’
/tmp/ccYKzhrU.o(.text+0x13d): In function ReSizeGLScene': : undefined reference to gluPerspective’
/tmp/ccYKzhrU.o(.text+0x14d): In function ReSizeGLScene': : undefined reference to glMatrixMode’
/tmp/ccYKzhrU.o(.text+0x165): In function DrawGLScene': : undefined reference to glClear’
/tmp/ccYKzhrU.o(.text+0x16d): In function DrawGLScene': : undefined reference to glLoadIdentity’
/tmp/ccYKzhrU.o(.text+0x172): In function DrawGLScene': : undefined reference to glutSwapBuffers’
/tmp/ccYKzhrU.o(.text+0x1a1): In function keyPressed': : undefined reference to glutDestroyWindow’
/tmp/ccYKzhrU.o(.text+0x1cf): In function main': : undefined reference to glutInit’
/tmp/ccYKzhrU.o(.text+0x1dc): In function main': : undefined reference to glutInitDisplayMode’
/tmp/ccYKzhrU.o(.text+0x1f1): In function main': : undefined reference to glutInitWindowSize’
/tmp/ccYKzhrU.o(.text+0x200): In function main': : undefined reference to glutInitWindowPosition’
/tmp/ccYKzhrU.o(.text+0x210): In function main': : undefined reference to glutCreateWindow’
/tmp/ccYKzhrU.o(.text+0x225): In function main': : undefined reference to glutDisplayFunc’
/tmp/ccYKzhrU.o(.text+0x22d): In function main': : undefined reference to glutFullScreen’
/tmp/ccYKzhrU.o(.text+0x23a): In function main': : undefined reference to glutIdleFunc’
/tmp/ccYKzhrU.o(.text+0x24a): In function main': : undefined reference to glutReshapeFunc’
/tmp/ccYKzhrU.o(.text+0x25a): In function main': : undefined reference to glutKeyboardFunc’
/tmp/ccYKzhrU.o(.text+0x277): In function main': : undefined reference to glutMainLoop’
collect2: ld returned 1 exit status
[root@localhost kane]#

Hi !

You might get more help if you post this message in the Linux forum.

I am not sure why you get the warning about the APIENTRY, it complains because both glut.h and gl.h defines APIENTRY…

All the linker errors are because you have missed to include the libraries on the commandline to gcc like “-lglut -lgl” or you have placed them in the incorrect order the gcc linker is picky about the order of the libraries, references to a library must come before the library option.

Mikael

Try compiling with something like…

gcc -o program main.cpp -I/usr/X11R6 -L/usr/X11R6/lib -lGL -lGLU -lglut -lXmu -lXi

Oooopss…

gcc -I/usr/X11R6/include -o program main.cpp -L/usr/X11R6/lib -lGL -lGLU -lglut -lXmu -lXi