Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtPlatformHeaders not available on macOS Qt 5.15.0



  • Trying to use QtPlatformHeaders in a qmake project leads to the following error:

    #include <QtPlatformHeaders/QCocoaNativeContext> // 'QtPlatformHeaders/QCocoaNativeContext' file not found
    

    I've tried making an empty project just to exclude my own project configuration, with the same result. It's as if Qt's entire include directory is just not available. It should be available out of the box according to the documentation:

    As the module is header-only, no further modifications to the .pro files are required to use it.
    
    Note: The module name (QtPlatformHeaders) must appear in the #include directive.
    
    Note: It is not necessary to enclose the code in #ifdef directives depending on platform.
    

    I had worked around this in previous Qt versions with a gigantic hack by adding the qtopenglextensions module, which in turn added its submodule to qmake's INCLUDEPATH, so that I could then define a relative includepath that'd actually make QtPlatformHeaders available:

    macx {
        QT += openglextensions
        INCLUDEPATH += "QtOpenGLExtensions/.."
    }
    

    However, this hack broke in 5.15 because the build configuration is looking for libQt5OpenGLExtensions_debug.a, but 5.15 only appears to ship with non-debug libraries (or there's no debug libraries, and the build configuration hasn't been updated accordingly). I'd rather not have to rely on a hack to begin with, so what am I missing?

    Somebody else had the same issue but never solved it--they ended up using a different method instead. Unfortunately, I do need the cocoa handle, not the CGL handle, so I have to go through this platform header.


  • Lifetime Qt Champion

    @cmartel said in QtPlatformHeaders not available on macOS Qt 5.15.0:

    #include <QtPlatformHeaders/QCocoaNativeContext>

    You should include without module name:

    #include <QCocoaNativeContext>
    


  • @jsulm said in QtPlatformHeaders not available on macOS Qt 5.15.0:

    @cmartel said in QtPlatformHeaders not available on macOS Qt 5.15.0:

    #include <QtPlatformHeaders/QCocoaNativeContext>

    You should include without module name:

    #include <QCocoaNativeContext>
    

    Sadly, even though the documentation says the module name must appear in the include, I think that was one of my first reactions when I first used platform headers in 5.12. I tried again, just in case:

    QtRenderManager_macOS.mm:6:10: fatal error: 'QCocoaNativeContext' file not found
    #include <QCocoaNativeContext>
             ^~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    make[1]: *** [QtRenderManager_macOS.o] Error 1
    

    Really, even though the documentation says no change to qmake project files is needed, that's not the case of any other Qt module so I find that rather suspicious. There's no global addition in qmake spec anywhere that'd make platform headers available. I took a peek at the source to see if there was a special case for QtPlatformHeaders, but couldn't find anything.

    Instead, what I noticed is that these headers are used from within the Qt libraries proper in a few places, but never in an example project or something that references Qt. To the extent that I wonder whether using these headers from within a client project was ever something that was tested, let alone supported.


  • Lifetime Qt Champion

    Hi,

    @jsulm said in QtPlatformHeaders not available on macOS Qt 5.15.0:

    @cmartel said in QtPlatformHeaders not available on macOS Qt 5.15.0:

    #include <QtPlatformHeaders/QCocoaNativeContext>

    You should include without module name:

    #include <QCocoaNativeContext>
    

    That is the one exception from the usual no module prefix for includes.

    @cmartel You should not need to have any hacks for these headers to be used. It looks that it could be an issue with the set of paths for these includes because they are available. You should check the but report system for that issue and if nothing can be found, please consider opening a new ticket for that. Note that I do not have that issue with my developer build of Qt.


Log in to reply