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

GLDEBUGPROC undefined due to include conflict with OpenSceneGraph

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.3
    • GUI: OpenGL
    • None
    • macOS

    Description

      The following program successfully compiles

      // qt_osg_bug.cpp
      #include <QOpenGLContext>
      #include <osg/Node>
      

      while this one fails (include order changed)

      // qt_osg_bug.cpp
      #include <osg/Node>
      #include <QOpenGLContext>
      

      with the error

      clang++ -I/opt/local/include -iframework /opt/local/libexec/qt5/lib -isystem /opt/local/libexec/qt5/lib/QtGui.framework/Headers -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers -isystem /opt/local/libexec/qt5/lib/QtOpenGL.framework/Headers -Wno-deprecated-declarations -std=c++14 -o qt_osg_bug.cpp.o -c qt_osg_bug.cpp
      In file included from qt_osg_bug.cpp:2:
      In file included from /opt/local/libexec/qt5/lib/QtGui.framework/Headers/QOpenGLContext:1:
      In file included from /opt/local/libexec/qt5/lib/QtGui.framework/Headers/qopenglcontext.h:61:
      /opt/local/libexec/qt5/lib/QtGui.framework/Headers/qopenglversionfunctions.h:1096:23: error: unknown type name 'GLDEBUGPROC'
          QT_OPENGL_DECLARE(QT_OPENGL_4_3_FUNCTIONS);
                            ^
      1 error generated.
      

      Both are compiled as follows:

      clang++ -I/opt/local/include -iframework /opt/local/libexec/qt5/lib -isystem /opt/local/libexec/qt5/lib/QtGui.framework/Headers -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers -isystem /opt/local/libexec/qt5/lib/QtOpenGL.framework/Headers -Wno-deprecated-declarations -std=c++14 -o qt_osg_bug.cpp.o -c qt_osg_bug.cpp
      

      The issue boils down to the inclusion order of these two files

      // qt_osg_bug.cpp
      #include <qopengl.h> // reachable from <QOpenGLContext>
      #include <osg/GLDefines> // reachable from <osg/Node>
      

      <qopegl.h:279> protects the declaration of GLDEBUGPROC with a define guard

      // qopegl.h:279
      #ifndef GL_KHR_debug
      typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam);
      #endif
      

      However, this macro is also defined by <osg/GLDefines> (here). So if <osg/GLDefines> is included before <qopengl.h> the function pointer GLDEBUGPROC is left undefined which leads to an error when it latter referenced in <qopenglversionfunctions.h>.

      I am not sure if OpenSceneGraph is at fault here and if GLDEBUGPROC prototype should be defined when GL_KHR_debug is defined.

      Guessing from code found in <qopenglextrafunctions.h:55> there have been attempts to fix similar issues for other systems. If this is not the right place please feel free to close this and hopefully point us to the right tracker.

      Note: while this report is for arm64 macOS 12.4, the issue is observed in macOS 10 on x86_64 as well.

      Attachments

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

        Activity

          People

            lagocs Laszlo Agocs
            mahge Mahder Gebremedhin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes