Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Undefined reference to glut
Forum Update on Monday, May 27th 2025

Undefined reference to glut

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
5 Posts 2 Posters 4.6k 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.
  • M Offline
    M Offline
    Morales1235
    wrote on last edited by
    #1

    Hello everyone,
    I'm new in using Debian and Qt. Tried to compile simple project, wrote by my friend in C::B. I was trying include all libraries, update debugger, compilers.. but still:

    ~/Dokumenty/projects/test7$ make
    g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/include/GL -I. -o main.o main.cpp
    main.cpp:80:56: warning: unused parameter ‘mouse_x’ [-Wunused-parameter]
     void FunkcjaDoObslugiKlawiatury(unsigned char key, int mouse_x, int mouse_y)
                                                            ^
    main.cpp:80:69: warning: unused parameter ‘mouse_y’ [-Wunused-parameter]
     void FunkcjaDoObslugiKlawiatury(unsigned char key, int mouse_x, int mouse_y)
                                                                         ^
    main.cpp: In function ‘int main(int, char**)’:
    main.cpp:142:35: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
      InitGLUTScene("freeglut template");
                                       ^
    g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/include/GL -I. -o Prostokat.o Prostokat.cpp
    Prostokat.cpp: In constructor ‘Prostokat::Prostokat()’:
    Prostokat.cpp:8:20: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
      m_kolor = { 1,0,0 };
                        ^
    Prostokat.cpp:8:10: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
      m_kolor = { 1,0,0 };
              ^
    Prostokat.cpp: In constructor ‘Prostokat::Prostokat(double, double, double, double)’:
    Prostokat.cpp:14:20: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
      m_kolor = { 1,0,0 };
                        ^
    Prostokat.cpp:14:10: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
      m_kolor = { 1,0,0 };
              ^
    g++ -m64 -Wl,-O1 -o test7 main.o Prostokat.o    -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread 
    main.o: In function `resize(int, int)':
    main.cpp:(.text+0x27): undefined reference to `glViewport'
    main.cpp:(.text+0x31): undefined reference to `glMatrixMode'
    main.cpp:(.text+0x36): undefined reference to `glLoadIdentity'
    main.cpp:(.text+0x74): undefined reference to `glFrustum'
    main.cpp:(.text+0xaa): undefined reference to `gluLookAt'
    main.cpp:(.text+0xb6): undefined reference to `glMatrixMode'
    main.o: In function `display()':
    main.cpp:(.text+0xea): undefined reference to `glClear'
    main.cpp:(.text+0xef): undefined reference to `glPushMatrix'
    main.cpp:(.text+0x104): undefined reference to `glTranslated'
    main.cpp:(.text+0x12d): undefined reference to `glRotated'
    main.cpp:(.text+0x152): undefined reference to `glTranslated'
    main.cpp:(.text+0x183): undefined reference to `glTranslated'
    main.cpp:(.text+0x1b0): undefined reference to `glRotated'
    main.cpp:(.text+0x1d9): undefined reference to `glTranslated'
    main.cpp:(.text+0x212): undefined reference to `glTranslated'
    main.cpp:(.text+0x242): undefined reference to `glRotated'
    main.cpp:(.text+0x271): undefined reference to `glTranslatef'
    main.cpp:(.text+0x289): undefined reference to `glPopMatrix'
    main.o: In function `InitGLUTScene(char*)':
    main.cpp:(.text+0x3cf): undefined reference to `glutInitWindowSize'
    main.cpp:(.text+0x3de): undefined reference to `glutInitWindowPosition'
    main.cpp:(.text+0x3e8): undefined reference to `glutInitDisplayMode'
    main.cpp:(.text+0x3f0): undefined reference to `glutCreateWindow'
    main.cpp:(.text+0x406): undefined reference to `glClearColor'
    main.cpp:(.text+0x410): undefined reference to `glEnable'
    main.cpp:(.text+0x41a): undefined reference to `glDepthFunc'
    main.cpp:(.text+0x424): undefined reference to `glEnable'
    main.cpp:(.text+0x42e): undefined reference to `glEnable'
    main.o: In function `SetCallbackFunctions()':
    main.cpp:(.text+0x44a): undefined reference to `glutReshapeFunc'
    main.cpp:(.text+0x454): undefined reference to `glutDisplayFunc'
    main.cpp:(.text+0x45e): undefined reference to `glutIdleFunc'
    main.o: In function `resize(int, int)':
    main.cpp:(.text+0xbf): undefined reference to `glLoadIdentity'
    main.o: In function `idle()':
    main.cpp:(.text+0xd1): undefined reference to `glutPostRedisplay'
    main.o: In function `display()':
    main.cpp:(.text+0x292): undefined reference to `glutSwapBuffers'
    main.o: In function `InitGLUTScene(char*)':
    main.cpp:(.text+0x439): undefined reference to `glEnable'
    main.o: In function `SetCallbackFunctions()':
    main.cpp:(.text+0x46c): undefined reference to `glutKeyboardFunc'
    main.o: In function `main':
    main.cpp:(.text.startup+0x13b): undefined reference to `glutInit'
    main.cpp:(.text.startup+0x14f): undefined reference to `glutMainLoop'
    Prostokat.o: In function `Prostokat::rysuj()':
    Prostokat.cpp:(.text+0xd9): undefined reference to `glPushMatrix'
    Prostokat.cpp:(.text+0xeb): undefined reference to `glTranslated'
    Prostokat.cpp:(.text+0xff): undefined reference to `glColor3d'
    Prostokat.cpp:(.text+0x109): undefined reference to `glBegin'
    Prostokat.cpp:(.text+0x143): undefined reference to `glVertex3d'
    Prostokat.cpp:(.text+0x164): undefined reference to `glVertex3d'
    Prostokat.cpp:(.text+0x18f): undefined reference to `glVertex3d'
    Prostokat.cpp:(.text+0x1be): undefined reference to `glVertex3d'
    Prostokat.cpp:(.text+0x1c3): undefined reference to `glEnd'
    Prostokat.cpp:(.text+0x1cd): undefined reference to `glPopMatrix'
    collect2: error: ld returned 1 exit status
    Makefile:105: polecenia dla obiektu 'test7' nie powiodły się
    make: *** [test7] Błąd 1
    
    

    Program was wrote on Windows, we were trying to set it on linux. When I was trying, there wasn't the first errors, just "undefined reference". Friend do something to run it in C::B - programs compiles. But not by Qt
    looks like error in linker? But What im doing wrong?
    int test7.pro:

    ######################################################################
    # Automatically generated by qmake (2.01a) niedz. gru 18 12:46:25 2016
    ######################################################################
    
    TEMPLATE = app
    TARGET = 
    DEPENDPATH += .
    INCLUDEPATH += /usr/include/GL
    # Input
    HEADERS += Prostokat.h sKolor.h
    SOURCES += main.cpp Prostokat.cpp
    
    

    The same errors when compiling i.e. tutorials from inernet. Thank you in advance!

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! First of all you're using ancient Qt 4, which is a bad idea for new code. Second, you need to link your application to the glut library, something like: -lglut.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Morales1235
        wrote on last edited by Morales1235
        #3

        Oh yes I found it.. using Qt5 now. Tried to include:

        INCLUDEPATH += /usr/include/GL -lglut -lGL -libglut -lfreeglut
        

        less errors, just:

        $ make clean
        $ qmake
        $ make
        g++ -m64 -Wl,-O1 -o test7 main.o Prostokat.o   -L/usr/X11R6/lib64 -lQt5Gui -lQt5Core -lGL -lpthread 
        main.o: In function `resize(int, int)':
        main.cpp:(.text+0xaa): undefined reference to `gluLookAt'
        main.o: In function `InitGLUTScene(char*)':
        main.cpp:(.text+0x3af): undefined reference to `glutInitWindowSize'
        main.cpp:(.text+0x3be): undefined reference to `glutInitWindowPosition'
        main.cpp:(.text+0x3c8): undefined reference to `glutInitDisplayMode'
        main.cpp:(.text+0x3d0): undefined reference to `glutCreateWindow'
        main.o: In function `SetCallbackFunctions()':
        main.cpp:(.text+0x42c): undefined reference to `glutReshapeFunc'
        main.cpp:(.text+0x438): undefined reference to `glutDisplayFunc'
        main.cpp:(.text+0x444): undefined reference to `glutIdleFunc'
        main.o: In function `idle()':
        main.cpp:(.text+0xd1): undefined reference to `glutPostRedisplay'
        main.o: In function `display()':
        main.cpp:(.text+0x27a): undefined reference to `glutSwapBuffers'
        main.o: In function `SetCallbackFunctions()':
        main.cpp:(.text+0x454): undefined reference to `glutKeyboardFunc'
        main.o: In function `main':
        main.cpp:(.text.startup+0x132): undefined reference to `glutInit'
        main.cpp:(.text.startup+0x148): undefined reference to `glutMainLoop'
        collect2: error: ld returned 1 exit status
        Makefile:137: polecenia dla obiektu 'test7' nie powiodły się
        make: *** [test7] Błąd 1
        
        

        tried to add every name of lib i found on internet...
        in includepath I should add path to *.h files?

        I also tried

        INCLUDEPATH += /usr/include/GL -lglut -lGL -libglut -lfreeglut \
        /usr/lib lglut -lGL -libglut -lfreeglut -llibglut
        

        what gives me more errors

        main.cpp: In function ‘int main(int, char**)’:
        main.cpp:163:35: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
          InitGLUTScene("freeglut template");
                                           ^
        g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -isystem /usr/include/GL -I-lglut -I-lGL -I-libglut -I-lfreeglut -I-llibglut -I/usr/lib -Ilglut -I-lGL -I-libglut -I-lfreeglut -I-llibglut -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -o Prostokat.o Prostokat.cpp
        Prostokat.cpp: In constructor ‘Prostokat::Prostokat()’:
        Prostokat.cpp:8:20: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
          m_kolor = { 1,0,0 };
                            ^
        Prostokat.cpp:8:10: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
          m_kolor = { 1,0,0 };
                  ^
        Prostokat.cpp: In constructor ‘Prostokat::Prostokat(double, double, double, double)’:
        Prostokat.cpp:14:20: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
          m_kolor = { 1,0,0 };
                            ^
        Prostokat.cpp:14:10: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
          m_kolor = { 1,0,0 };
                  ^
        g++ -m64 -Wl,-O1 -o test7 main.o Prostokat.o   -L/usr/X11R6/lib64 -lQt5Gui -lQt5Core -lGL -lpthread 
        main.o: In function `resize(int, int)':
        main.cpp:(.text+0xaa): undefined reference to `gluLookAt'
        main.o: In function `InitGLUTScene(char*)':
        main.cpp:(.text+0x3af): undefined reference to `glutInitWindowSize'
        main.cpp:(.text+0x3be): undefined reference to `glutInitWindowPosition'
        main.cpp:(.text+0x3c8): undefined reference to `glutInitDisplayMode'
        main.cpp:(.text+0x3d0): undefined reference to `glutCreateWindow'
        main.o: In function `SetCallbackFunctions()':
        main.cpp:(.text+0x42c): undefined reference to `glutReshapeFunc'
        main.cpp:(.text+0x438): undefined reference to `glutDisplayFunc'
        main.cpp:(.text+0x444): undefined reference to `glutIdleFunc'
        main.o: In function `idle()':
        main.cpp:(.text+0xd1): undefined reference to `glutPostRedisplay'
        main.o: In function `display()':
        main.cpp:(.text+0x27a): undefined reference to `glutSwapBuffers'
        main.o: In function `SetCallbackFunctions()':
        main.cpp:(.text+0x454): undefined reference to `glutKeyboardFunc'
        main.o: In function `main':
        main.cpp:(.text.startup+0x132): undefined reference to `glutInit'
        main.cpp:(.text.startup+0x148): undefined reference to `glutMainLoop'
        collect2: error: ld returned 1 exit status
        Makefile:137: polecenia dla obiektu 'test7' nie powiodły się
        make: *** [test7] Błąd 1
        
        
        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          It should more look like this:

          INCLUDEPATH += /path/to/glut/include  # where the header files are
          LIBPATH     += /path/to/glut/lib # where the shared object files  are
          LIBS        += -lglut # name of the library
          
          1 Reply Last reply
          1
          • M Offline
            M Offline
            Morales1235
            wrote on last edited by
            #5

            Thank you!
            I also had to add -lGL and -lGLU. Works

            1 Reply Last reply
            1

            • Login

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