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. Undefined references in OpenGL
Forum Updated to NodeBB v4.3 + New Features

Undefined references in OpenGL

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
4 Posts 3 Posters 2.0k Views 2 Watching
  • 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.
  • F Offline
    F Offline
    Forfunckle
    wrote on 30 Jun 2019, 13:21 last edited by
    #1

    When I try building an OpenGL program I always get these "undefined reference" errors:
    debug/main.o: In function `glutInit_ATEXIT_HACK': C:/glut/GL/glut.h:486: undefined reference to `_imp____glutInitWithExit' debug/main.o: In function `glutCreateWindow_ATEXIT_HACK': C:/glut/GL/glut.h:503: undefined reference to `_imp____glutCreateWindowWithExit' debug/main.o: In function `glutCreateMenu_ATEXIT_HACK': C:/glut/GL/glut.h:549: undefined reference to `_imp____glutCreateMenuWithExit' collect2.exe: error: ld returned 1 exit status mingw32-make[1]: *** [Makefile.Debug:75: debug/Height.exe] Error 1 mingw32-make[1]: Leaving directory 'C:/Users/Alis/Documents/build-Height-Desktop_Qt_5_13_0_MinGW_32_bit-Debug' mingw32-make: *** [Makefile:38: debug] Error 2 16:14:34: The process "C:\Qt\Qt5.13.0\Tools\mingw730_32\bin\mingw32-make.exe" exited with code 2.
    I linked my files like this:
    LIBS += -lopengl32
    LIBS += -lglut -lGLUT -m32 -lglu32 -lgdi32 -lfreeglut
    Then I right-clicked my project folder and pressed "Add Library" to link my .lib file. What am I doing wrong?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 30 Jun 2019, 13:28 last edited by
      #2

      Hi
      Try adding
      #define GLUT_DISABLE_ATEXIT_HACK
      before your first glut.h include.
      https://community.khronos.org/t/glut-undefined/14242

      Its a shot in the dark, however, it seems to find all the other functions so i dont think
      its just due not finding the libs to link with.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Forfunckle
        wrote on 30 Jun 2019, 13:46 last edited by
        #3

        I forgot to mention that I have already added that line. Before adding it there were 8 of these errors, now they are only 4

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 30 Jun 2019, 14:56 last edited by Chris Kawa
          #4

          -lglut -lGLUT -lfreeglut

          First of all glut and GLUT are the same so that's redundant. Second, glut and freeglut are two different libraries. Which one are you actually using? Third, if you're using glut then the lib is (usually) called glut32, not glut, so check what the name of the .lib or .a file actually is.
          Next, you need to specify the path to the library ie. LIBS += -Lpath_to_glut_or_freeglut_lib_dir . Last but not least - after you make changes to the .pro file make sure you re-run qmake (menu Build - >Run qmake), otherwise those changes might not get picked up.

          1 Reply Last reply
          3

          1/4

          30 Jun 2019, 13:21

          • Login

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