[SOLVED] Build failure : undefined reference to `gluPerspective'
I have a build error when I try to build my Qt project with QtCreator. "undefined reference to `gluPerspective'".
My .pro file is :
My mafenetre.cpp file (the error comes from this file):
void MaFenetre::resizeGL(int width, int height)
gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 100.0f);
I don't understand why I have this error when I try to build my project. I have included the <GL/glu.h>, link opengl lib to my project...
If someone has an idea...
You need to provide more information: What OS ? What compiler ? What Qt version ?
Ubuntu 12.10 with Qt 5.0.1 on QtCreator and g++.
IIRC gluPerspective comes from the glut (freeglut ?) library. Are you linking against the glut library ?
I tried using gluPerspective with SDL a few weeks ago and it works with the #include <GL/glu.h>...
Why don't you try glFrustum() instead ?
Including glu.h has nothing to do with linking the library. Did you check that your program is linked with glut ?
What version of OpenGL are you using ? IIRC gluPerspective has been removed since OpenGL 3.0.
You can also find an implementation called qgluPerspective in the Boxes example
I know for the gluPerspective removal since OpenGL 3.x. It's the OpenGL's version I have but as I said glPerspective works with another project with the SDL Library (and same compiler, OpenGL 3.x...) ; that's weird I know... if the glPerspective has been removed...
I'm going to check if my QtCreator is linked with glut ASAP... but it's GLU, not GLUT, I think. If it was GLUT my function should be glutPerspective, no?
@john_god, what's the difference between this function and gluPerspective?
It's GLUT (GLUT stands for OpenGL Utility Toolkit)
gluPerspective does some mathematic for you and then uses glFrustrum. Either search for the implementation on google, or grep qgluPerspective in your Qt 5 sources.
[quote author="Zikkee13" date="1365005409"]@john_god, what's the difference between this function and gluPerspective?[/quote]
I'm too lazy to check the specs right now but I think they are the same, the diference is that gluPerspective adds GLUT dependency to your project, glFrustum() is OpenGL native.
Go check it out on google :)
Edit: Ok I just check them, they are no the same, please check glOrtho(). Basically all this functions do is to setup diferent math perspectives / projections to your world.
I have added GLU .so file (/usr/lib/i386-linux-gnu/libGLU.so) to my project and it works.
GLUT is not installed on my laptop and it works without it.
Thanks for your help. Solved.
Edit : @john_god, OK thanks!
Hello, I have same problem compiling a project in qt5,
@ undefined reference to gluPerspective@
@undefined reference to gluLookAt@
i'm on Debian Wheezy 64bit ..
I had the same problem as gaia and solved it by adding
@LIBS += -lglut -lGLU@
to the .pro file of my project