QtOpenGL and GL Libraries conflict

  • I am trying to do an opengl example from a video on youtube. I am doing the same thing but in glEnable(GL_LIGHT0); line my qt gives error. It gives error also for GL_LIGHTING, GL_COLOR_MATERIAL. Error is; GL_LIGHT0 was not declared in this scope. Later I added #include <GL/glu.h> and program recognized this enable methods but at this time gave another error which is: conflicting decleration 'typedef double GLdouble' and other conflicting errors. How to declare these methods. In the video he does not have such an error. Thank you inadvance.

  • The problem is for adding include<QGLWidget> we need opengl library. We add this in pro file. For using glBegin, glVertex3d, glColor3f methods we need to include GL/gl.h library. But when this has been added, qt gives conflict error.

  • Lifetime Qt Champion


    Which version of Qt are you using ?

    If Qt 5, then you should consider using QOpenGLWidget. In the documentation of the class here, you have the explanation on how to call standard OpenGL functions.

  • @SGaist I downloaded qt default and this is qt 5.3.2. Later I downloaded qt everywhere 5.9. I referenced both of them in the tools Option, Qt Versions tab.

  • @aysenur FYI, if you are learning glBegin and glEnd, you are learning some very outdated and deprecated functionality. A modern OpenGL "Core" Profile will no longer support that functionality.

  • @wrosecrans Thank you for your reply. What do you prefer ? I want to view stl file, I found different examples like e8johan stlviewer from github. It works on ubuntu in my computer but when I downloded it on my raspberry pi it gives conflict error. Stlviewer both uses opengl and GL libraries at the same time.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.