Search code examples
c++qtopenglqt5.5

How to resolve 'undefined references' in OpenGL C++ Qt5.5


I have downloaded Earth10 from GitHub and when i compile it in Qt5.3_MinGW with QGLWidget then it works but when i compile it in Qt5.5_MinGW with QOpenGLWidget then it pop up "undefined reference to `_imp__glPolygonMode@8'" etc errors. What can i change in source code to get rid of such errors? Or if someone can point me to port from QGLWidget to QOpenGLWidget that would also be helpful.

One quick hack for removing all errors was:

enter image description here

CONFIG += c++11
LIBS   += -lopengl32
LIBS   += -lglu32
LIBS   += -lglut32

Solution

  • Add opengl32.lib to the libraries linked by the linker stage.

    Paraboloid87 showed the exact code which is required to add opengl32.lib:

    Add LIBS += -lopengl32 to your *.pro file.