Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-34174

Conflict between GL/glx.h and qt/QtGui/qopengl.h

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 5.1.1
    • GUI: OpenGL
    • None
    • Arch Linux version 3.11.5-1-ARCH x86_64. Nvidia 325.15-10 proprietary drivers.
      Qt 5.1.1-2 (x86 64bit) OpenGL Desktop build. gcc 4.8.1 (x86 64bit).

    Description

      Issue:

      Including glx.h and qopengl.h in a project results in conflicting declarations. It also leads to a declaration conflict between glxext.h and qopengles2ext.h.

      Compile errors:

      Compile Output
      g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I../glxerror -I/usr/include/qt -I/usr/include/qt/QtOpenGL -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -I. -o main.o ../glxerror/main.cpp
      In file included from /usr/include/GL/glx.h:32:0,
                       from ../glxerror/main.cpp:5:
      /usr/include/GL/gl.h:162:17: error: conflicting declaration 'typedef double GLdouble'
       typedef double  GLdouble; /* double precision float */
                       ^
      In file included from ../glxerror/main.cpp:4:0:
      /usr/include/qt/QtGui/qopengl.h:97:17: error: 'GLdouble' has a previous declaration as 'typedef GLfloat GLdouble'
       typedef GLfloat GLdouble;
                       ^
      In file included from /usr/include/GL/gl.h:2085:0,
                       from /usr/include/GL/glx.h:32,
                       from ../glxerror/main.cpp:5:
      /usr/include/GL/glext.h:2169:149: error: conflicting declaration 'typedef void (* GLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, const void*)'
       typedef void (APIENTRY  *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
                                                                                                                                                           ^
      In file included from /usr/include/qt/QtGui/qopengl.h:92:0,
                       from ../glxerror/main.cpp:4:
      /usr/include/qt/QtGui/qopengles2ext.h:192:28: error: 'GLDEBUGPROC' has a previous declaration as 'typedef void (* GLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*)'
       typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
                                  ^
      make: *** [main.o] Error 1
      13:00:05: The process "/usr/bin/make" exited with code 2.
      Error while building/deploying project glxerror (kit: Qt 5)
      When executing step 'Make'
      

      Reproducing the error:

      Depending on your system, the following code might reproduce the issue.

      main.cpp
      #include <QApplication>
      
      #include <qt/QtGui/qopengl.h>
      #include <GL/glx.h>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          return a.exec();
      }
      

      Motivation:

      glx.h is needed in order to create an OpenCL context with OpenGL interopability. Typically, this would look like:

      clgl_interop.cpp
      #ifdef Q_OS_LINUX
          cl_context_properties properties[] = {
              CL_GL_CONTEXT_KHR, (cl_context_properties) glXGetCurrentContext(),
              CL_GLX_DISPLAY_KHR, (cl_context_properties) glXGetCurrentDisplay(),
              CL_CONTEXT_PLATFORM, (cl_context_properties) main_device->getPlatformId(),
              0};
      #endif
      

      If there are alternate calls for glXGetCurrentContext() and glXGetCurrentDisplay() within Qt, please let me know.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sletta Gunnar Sletta
            natnux Andreas Reiten
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes