Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CMAKE finds EGL, Qt does not: tiny bug in Qt's FindEGL.cmake prevents linking with static Qt

CMAKE finds EGL, Qt does not: tiny bug in Qt's FindEGL.cmake prevents linking with static Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
static buildeglcmake
3 Posts 3 Posters 720 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BwvB
    wrote on last edited by
    #1

    Recently, I ran into a problem with the static version Qt 6.4.2. that other people might also encounter. Fortunately, I found a solution, which I share in this post.

    After I succesfully compiled and linked my application with the Qt 6.4.2 (default build, i.e. dynamic libraries), I tried to build and link the same application again, but now with a static build of Qt 6.4.2.
    Building static Qt 6.4.2 was not a problem, but the cmake configuration of my own application failed, however.
    The error messages indicated that the opengl library EGL could not be found. Because of this, linking to the Qt components I used (Gui, Widgets, ...) failed, with the error message telling that the test HAVE_EGL failed.

    This was weird, as cmake in the same configuration run could find all the required opengl components! It turned out the culprit was in the file FindEGL.cmake, which comes with the Qt distribution (../lib/cmake/Qt6/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake). In this file, there is the snippet:

    check_cxx_source_compiles("
    #include <EGL/egl.h>
    
    int main(int, char **) {
        EGLint x= 0; EGLDisplay dpy = 0; EGLContext ctx = 0;
        eglDestroyContext(dpy, ctx);
    }" HAVE_EGL)
    

    The variable EGLint x=0; is not used elsewhere in this code snippet, triggering a warning from the compiler. The warning was treated as an error and the test failed accordingly. A resolution is to add the attribute [[maybe_unused]] immediately following x:

    check_cxx_source_compiles("
    #include <EGL/egl.h>
    
    int main(int, char **) {
        EGLint x [[maybe_unused]] = 0; EGLDisplay dpy = 0; EGLContext ctx = 0;
        eglDestroyContext(dpy, ctx);
    }" HAVE_EGL)
    

    With this, the cmake-configuration of my application could again proceed as intended, after which compilation and linking to static Qt was possible.

    Christian EhrlicherC 1 Reply Last reply
    0
    • B BwvB

      Recently, I ran into a problem with the static version Qt 6.4.2. that other people might also encounter. Fortunately, I found a solution, which I share in this post.

      After I succesfully compiled and linked my application with the Qt 6.4.2 (default build, i.e. dynamic libraries), I tried to build and link the same application again, but now with a static build of Qt 6.4.2.
      Building static Qt 6.4.2 was not a problem, but the cmake configuration of my own application failed, however.
      The error messages indicated that the opengl library EGL could not be found. Because of this, linking to the Qt components I used (Gui, Widgets, ...) failed, with the error message telling that the test HAVE_EGL failed.

      This was weird, as cmake in the same configuration run could find all the required opengl components! It turned out the culprit was in the file FindEGL.cmake, which comes with the Qt distribution (../lib/cmake/Qt6/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake). In this file, there is the snippet:

      check_cxx_source_compiles("
      #include <EGL/egl.h>
      
      int main(int, char **) {
          EGLint x= 0; EGLDisplay dpy = 0; EGLContext ctx = 0;
          eglDestroyContext(dpy, ctx);
      }" HAVE_EGL)
      

      The variable EGLint x=0; is not used elsewhere in this code snippet, triggering a warning from the compiler. The warning was treated as an error and the test failed accordingly. A resolution is to add the attribute [[maybe_unused]] immediately following x:

      check_cxx_source_compiles("
      #include <EGL/egl.h>
      
      int main(int, char **) {
          EGLint x [[maybe_unused]] = 0; EGLDisplay dpy = 0; EGLContext ctx = 0;
          eglDestroyContext(dpy, ctx);
      }" HAVE_EGL)
      

      With this, the cmake-configuration of my application could again proceed as intended, after which compilation and linking to static Qt was possible.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You should create a bug report about this - most of the Qt devs don't read in the forum.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      SGaistS 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        You should create a bug report about this - most of the Qt devs don't read in the forum.

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        That part comes from KDE, I would recommend also checking with them.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved