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 toglClearColor’
/tmp/ccYKzhrU.o(.text+0x36): In function InitGL': : undefined reference toglClearDepth’
/tmp/ccYKzhrU.o(.text+0x46): In function InitGL': : undefined reference toglDepthFunc’
/tmp/ccYKzhrU.o(.text+0x56): In function InitGL': : undefined reference toglEnable’
/tmp/ccYKzhrU.o(.text+0x66): In function InitGL': : undefined reference toglShadeModel’
/tmp/ccYKzhrU.o(.text+0x76): In function InitGL': : undefined reference toglMatrixMode’
/tmp/ccYKzhrU.o(.text+0x7e): In function InitGL': : undefined reference toglLoadIdentity’
/tmp/ccYKzhrU.o(.text+0xb6): In function InitGL': : undefined reference togluPerspective’
/tmp/ccYKzhrU.o(.text+0xc6): In function InitGL': : undefined reference toglMatrixMode’
/tmp/ccYKzhrU.o(.text+0xed): In function ReSizeGLScene': : undefined reference toglViewport’
/tmp/ccYKzhrU.o(.text+0xfd): In function ReSizeGLScene': : undefined reference toglMatrixMode’
/tmp/ccYKzhrU.o(.text+0x105): In function ReSizeGLScene': : undefined reference toglLoadIdentity’
/tmp/ccYKzhrU.o(.text+0x13d): In function ReSizeGLScene': : undefined reference togluPerspective’
/tmp/ccYKzhrU.o(.text+0x14d): In function ReSizeGLScene': : undefined reference toglMatrixMode’
/tmp/ccYKzhrU.o(.text+0x165): In function DrawGLScene': : undefined reference toglClear’
/tmp/ccYKzhrU.o(.text+0x16d): In function DrawGLScene': : undefined reference toglLoadIdentity’
/tmp/ccYKzhrU.o(.text+0x172): In function DrawGLScene': : undefined reference toglutSwapBuffers’
/tmp/ccYKzhrU.o(.text+0x1a1): In function keyPressed': : undefined reference toglutDestroyWindow’
/tmp/ccYKzhrU.o(.text+0x1cf): In function main': : undefined reference toglutInit’
/tmp/ccYKzhrU.o(.text+0x1dc): In function main': : undefined reference toglutInitDisplayMode’
/tmp/ccYKzhrU.o(.text+0x1f1): In function main': : undefined reference toglutInitWindowSize’
/tmp/ccYKzhrU.o(.text+0x200): In function main': : undefined reference toglutInitWindowPosition’
/tmp/ccYKzhrU.o(.text+0x210): In function main': : undefined reference toglutCreateWindow’
/tmp/ccYKzhrU.o(.text+0x225): In function main': : undefined reference toglutDisplayFunc’
/tmp/ccYKzhrU.o(.text+0x22d): In function main': : undefined reference toglutFullScreen’
/tmp/ccYKzhrU.o(.text+0x23a): In function main': : undefined reference toglutIdleFunc’
/tmp/ccYKzhrU.o(.text+0x24a): In function main': : undefined reference toglutReshapeFunc’
/tmp/ccYKzhrU.o(.text+0x25a): In function main': : undefined reference toglutKeyboardFunc’
/tmp/ccYKzhrU.o(.text+0x277): In function main': : undefined reference toglutMainLoop’
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