Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [SOLVED] Build failure : undefined reference to `gluPerspective'
QtWS25 Last Chance

[SOLVED] Build failure : undefined reference to `gluPerspective'

Scheduled Pinned Locked Moved Installation and Deployment
13 Posts 5 Posters 27.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zikkee13
    wrote on 3 Apr 2013, 12:31 last edited by
    #1

    Hello everbody,

    I have a build error when I try to build my Qt project with QtCreator. "undefined reference to `gluPerspective'".
    My .pro file is :

    @SOURCES +=
    main.cpp
    monwidgetopengl.cpp
    mafenetre.cpp

    HEADERS +=
    monwidgetopengl.h
    mafenetre.h
    QT+= opengl
    QT+= widgets@

    My mafenetre.cpp file (the error comes from this file):

    @#include "mafenetre.h"
    #include <GL/glu.h>

    // ...

    // ...
    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...
    Thanks!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Apr 2013, 12:38 last edited by
      #2

      Hi,

      You need to provide more information: What OS ? What compiler ? What Qt version ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zikkee13
        wrote on 3 Apr 2013, 12:43 last edited by
        #3

        Ubuntu 12.10 with Qt 5.0.1 on QtCreator and g++.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 3 Apr 2013, 12:57 last edited by
          #4

          IIRC gluPerspective comes from the glut (freeglut ?) library. Are you linking against the glut library ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            Zikkee13
            wrote on 3 Apr 2013, 13:07 last edited by
            #5

            I tried using gluPerspective with SDL a few weeks ago and it works with the #include <GL/glu.h>...

            1 Reply Last reply
            0
            • J Offline
              J Offline
              john_god
              wrote on 3 Apr 2013, 13:09 last edited by
              #6

              Why don't you try glFrustum() instead ?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 3 Apr 2013, 13:23 last edited by
                #7

                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

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  Zikkee13
                  wrote on 3 Apr 2013, 16:10 last edited by
                  #8

                  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?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 3 Apr 2013, 19:34 last edited by
                    #9

                    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.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      john_god
                      wrote on 3 Apr 2013, 21:01 last edited by
                      #10

                      [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.

                      1 Reply Last reply
                      0
                      • Z Offline
                        Z Offline
                        Zikkee13
                        wrote on 3 Apr 2013, 21:25 last edited by
                        #11

                        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!

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          gaia
                          wrote on 2 Nov 2013, 10:25 last edited by
                          #12

                          Hello, I have same problem compiling a project in qt5,
                          @ undefined reference to gluPerspective@
                          @undefined reference to gluLookAt@

                          i'm on Debian Wheezy 64bit ..

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            soleyla
                            wrote on 11 Jul 2014, 10:23 last edited by
                            #13

                            I had the same problem as gaia and solved it by adding

                            @LIBS += -lglut -lGLU@

                            to the .pro file of my project

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved