PDA

View Full Version : Undefined reference to gluPerspective



FattyOwl
08-23-2010, 05:49 PM
I am trying to learn OpenGL using these tutorials:
http://www.videotutorialsrock.com/opengl_tutorial/get_opengl_setup_linux/video.php

They told me to download a source file and compile it. It should result in a spinning cube.

However when I try to compile it it gives me the following error:

kobe@kobe-laptop:~/Tutorials/Cube$ make
g++ -Wall -o cube main.cpp imageloader.cpp -lglut
imageloader.cpp: In function ‘Image* loadBMP(const char*)’:
imageloader.cpp:141: warning: suggest parentheses around ‘&&’ within ‘||’
/tmp/ccDxFyfp.o: In function `handleResize(int, int)':
main.cpp:(.text+0x18b): undefined reference to `gluPerspective'
collect2: ld returned 1 exit status
make: *** [cube] Error 1


I have got all the header files that are required installed. How can I solve this problem?

Thanks in advance!

Dark Photon
08-23-2010, 06:24 PM
$ make
g++ -Wall -o cube main.cpp imageloader.cpp -lglut
...
/tmp/ccDxFyfp.o: In function `handleResize(int, int)':
main.cpp:(.text+0x18b): undefined reference to `gluPerspective'
...
I have got all the header files that are required installed. How can I solve this problem?
This isn't a header file issue. Header files are for compiling. This is a linking issue. It needs a library that contains gluPerspective. That library is libGLU.

Try:

g++ -Wall -o cube main.cpp imageloader.cpp -lglut -lGLU -lGL

FattyOwl
08-24-2010, 04:23 AM
$ make
g++ -Wall -o cube main.cpp imageloader.cpp -lglut
...
/tmp/ccDxFyfp.o: In function `handleResize(int, int)':
main.cpp:(.text+0x18b): undefined reference to `gluPerspective'
...
I have got all the header files that are required installed. How can I solve this problem?
This isn't a header file issue. Header files are for compiling. This is a linking issue. It needs a library that contains gluPerspective. That library is libGLU.

Try:

g++ -Wall -o cube main.cpp imageloader.cpp -lglut -lGLU -lGL


Thank you, that worked!