Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    static build egl cmake
    3
    3
    35
    Loading More Posts
    • 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
      BwvB last edited by

      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 Ehrlicher 1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion @BwvB last edited by

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

        Qt has to stay free or it will die.

        SGaist 1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion @Christian Ehrlicher last edited by

          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 Reply Quote 0
          • First post
            Last post