Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
To: buildroot@buildroot.org
Cc: Paul Louvel <paul.louvel@bootlin.com>,
	Giulio Benetti <giulio.benetti@benettiengineering.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	"Yann E . MORIN" <yann.morin.1998@free.fr>,
	Thomas Ballasi <thomas.ballasi@savoirfairelinux.com>,
	Nico Orlando <nico.orlando@dave.eu>,
	Roberto Zelbi <roberto.zelbi@dave.eu>,
	Angelo Compagnucci <angelo.compagnucci@gmail.com>
Subject: [Buildroot] [PATCH v2 1/2] package/qt5/qt5base: export the OpenGL and EGL library dirs to CMake
Date: Fri,  6 Nov 2026 15:34:08 +0100	[thread overview]
Message-ID: <20261106143409.2581133-1-angelo.compagnucci@gmail.com> (raw)
In-Reply-To: <20260605111256.107837-1-paul.louvel@bootlin.com>

When the OpenGL ES2, OpenGL or EGL libraries are found with pkg-config,
as in Buildroot, their directory only ends up as a -L flag in
QMAKE_LIBS_OPENGL_ES2, QMAKE_LIBS_OPENGL or QMAKE_LIBS_EGL. qtbase drops
it when generating Qt5GuiConfigExtras.cmake, whose find_library(...
NO_DEFAULT_PATH) then never finds the libraries:

  -- Qt OpenGL implementation: GLESv2
  -- Qt OpenGL libraries:
  -- Qt EGL libraries:

So Qt5Gui_OPENGL_LIBRARIES and Qt5Gui_EGL_LIBRARIES are empty for every
CMake project using them, and qt5webkit with OpenGL ES2 (qt5base OpenGL
support, which enables its WebKit2/QML API) fails to link libWebCore:

  GraphicsContext3DOpenGLES.cpp: undefined reference to `glBindRenderbuffer'
  ...: undefined reference to `eglGetProcAddress'

Add a patch exporting the directories given with -L when QMAKE_LIBDIR_*
are not set.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changes v1 -> v2:
  - new patch: with the OpenGL support of qt5base, which enables the
    WebKit2 QML API of qt5webkit, libWebCore fails to link because
    Qt5Gui_OPENGL_LIBRARIES and Qt5Gui_EGL_LIBRARIES are empty.

Tested: Bootlin x86_64 glibc stable toolchain, qt5base with OpenGL ES2
(mesa3d softpipe, EGL) and eglfs, qt5declarative, qt5webkit (WebKit2 ON) and
qt-webkit-kiosk: everything builds, Qt reports "Qt OpenGL libraries:
Qt5::Gui_GLESv2" and "Qt EGL libraries: Qt5::Gui_EGL", libWebCore links
libGLESv2/libEGL, the qt_lib_webkit*.pri files are in
$(HOST_DIR)/mkspecs/modules, the headers in $(STAGING_DIR)/usr/include/qt5,
and the QtWebKit QML module in both $(STAGING_DIR)/usr/qml and
$(TARGET_DIR)/usr/qml. Not run-time tested.

 ...penGL-and-EGL-library-dirs-found-wit.patch | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 package/qt5/qt5base/0012-gui-export-the-OpenGL-and-EGL-library-dirs-found-wit.patch

diff --git a/package/qt5/qt5base/0012-gui-export-the-OpenGL-and-EGL-library-dirs-found-wit.patch b/package/qt5/qt5base/0012-gui-export-the-OpenGL-and-EGL-library-dirs-found-wit.patch
new file mode 100644
index 0000000000..6ab60937de
--- /dev/null
+++ b/package/qt5/qt5base/0012-gui-export-the-OpenGL-and-EGL-library-dirs-found-wit.patch
@@ -0,0 +1,82 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
+Date: Fri, 6 Nov 2026 14:27:11 +0100
+Subject: [PATCH] gui: export the OpenGL and EGL library dirs found with -L to
+ CMake
+
+When the OpenGL ES2, OpenGL or EGL libraries are detected with
+pkg-config, their library directory ends up as a -L flag in
+QMAKE_LIBS_OPENGL_ES2, QMAKE_LIBS_OPENGL or QMAKE_LIBS_EGL, while
+QMAKE_LIBDIR_* stay empty.
+
+cmakeProcessLibs() drops the -L flags, so the generated
+Qt5GuiConfigExtras.cmake calls _qt5gui_find_extra_libs() with an empty
+library directory, and its find_library(... NO_DEFAULT_PATH) never finds
+the libraries: Qt5Gui_OPENGL_LIBRARIES and Qt5Gui_EGL_LIBRARIES are
+empty, and CMake projects using them (e.g. QtWebKit with OpenGL ES2)
+fail to link with undefined references to the gl* and egl* functions.
+
+Use the directories given with -L when QMAKE_LIBDIR_* are not set.
+
+Upstream: N/A, Qt 5 is end of life and Qt 6 builds with CMake
+Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
+---
+ mkspecs/features/cmake_functions.prf | 12 ++++++++++++
+ src/gui/gui.pro                      |  4 ++++
+ 2 files changed, 16 insertions(+)
+
+diff --git a/mkspecs/features/cmake_functions.prf b/mkspecs/features/cmake_functions.prf
+index 0c62b46..1b217ef 100644
+--- a/mkspecs/features/cmake_functions.prf
++++ b/mkspecs/features/cmake_functions.prf
+@@ -71,6 +71,18 @@ defineReplace(cmakeProcessLibs) {
+     return ($$join(out, ";"))
+ }
+ 
++defineReplace(cmakeProcessLibDirs) {
++    variable = $$1
++    out =
++    for(v, variable) {
++        contains(v, -L.*) {
++            v ~= s,^-L,,
++            out += $$v
++        }
++    }
++    return ($$out)
++}
++
+ defineReplace(cmakeRelativePath) {
+     path = $$relative_path($$1, $$2)
+     return($$replace(path, ([^/])$, \\1/))
+diff --git a/src/gui/gui.pro b/src/gui/gui.pro
+index 20372d9..21b5d55 100644
+--- a/src/gui/gui.pro
++++ b/src/gui/gui.pro
+@@ -76,6 +76,8 @@ qtConfig(angle) {
+     qtConfig(egl) {
+         CMAKE_EGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_EGL)
+         !isEmpty(QMAKE_LIBDIR_EGL): CMAKE_EGL_LIBDIR += $$cmakeTargetPath($$QMAKE_LIBDIR_EGL)
++        else: for(dir, $$list($$cmakeProcessLibDirs($$QMAKE_LIBS_EGL))): \
++            CMAKE_EGL_LIBDIR += $$cmakeTargetPath($$dir)
+     }
+ 
+     qtConfig(opengles2) {
+@@ -83,6 +85,7 @@ qtConfig(angle) {
+         CMAKE_OPENGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_OPENGL_ES2)
+         CMAKE_OPENGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_OPENGL_ES2)
+         !isEmpty(QMAKE_LIBDIR_OPENGL_ES2): CMAKE_OPENGL_LIBDIR = $$cmakePortablePaths($$QMAKE_LIBDIR_OPENGL_ES2)
++        else: CMAKE_OPENGL_LIBDIR = $$cmakePortablePaths($$cmakeProcessLibDirs($$QMAKE_LIBS_OPENGL_ES2))
+         CMAKE_GL_HEADER_NAME = GLES2/gl2.h
+         CMAKE_QT_OPENGL_IMPLEMENTATION = GLESv2
+     } else: qtConfig(opengl) {
+@@ -90,6 +93,7 @@ qtConfig(angle) {
+         CMAKE_OPENGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_OPENGL)
+         !qtConfig(dynamicgl): CMAKE_OPENGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_OPENGL)
+         !isEmpty(QMAKE_LIBDIR_OPENGL): CMAKE_OPENGL_LIBDIR = $$cmakePortablePaths($$QMAKE_LIBDIR_OPENGL)
++        else: CMAKE_OPENGL_LIBDIR = $$cmakePortablePaths($$cmakeProcessLibDirs($$QMAKE_LIBS_OPENGL))
+         CMAKE_GL_HEADER_NAME = GL/gl.h
+         mac: CMAKE_GL_HEADER_NAME = gl.h
+         CMAKE_QT_OPENGL_IMPLEMENTATION = GL
+-- 
+2.34.1
+
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2026-11-06 14:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 11:12 [Buildroot] [PATCH] package/qt5/qt5webkit: fix QMake-generated artifacts location and content Paul Louvel via buildroot
2026-11-06 14:34 ` Angelo Compagnucci [this message]
2026-11-06 14:34   ` [Buildroot] [PATCH v2 2/2] " Angelo Compagnucci

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106143409.2581133-1-angelo.compagnucci@gmail.com \
    --to=angelo.compagnucci@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=giulio.benetti@benettiengineering.com \
    --cc=nico.orlando@dave.eu \
    --cc=paul.louvel@bootlin.com \
    --cc=roberto.zelbi@dave.eu \
    --cc=thomas.ballasi@savoirfairelinux.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=yann.morin.1998@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox