Meson fails to find libdrm_fourcc.h for GStreamer 1.26.6, while it worked for 1.24.0?

I’ve finally migrated to Conan 2 (oh my..) to make it work with newer Meson (I’m now using 1.7.2) so I could build latest GStreamer…

But with 1.26.6, libgstgl (gst-plugins-base) is built on Debian 12 without gst_gl_display_x11_new_with_display, so libgstqmlgl (gst-plugins-good) integration with Qt does not work…

If we look at 1.24.0 build Meson log, we see that it finds drm_fourcc.h:

Running compile:
Working directory:  /home/vincas/.conan2/p/b/gst-p0d93f0835b072/b/build-release/meson-private/tmp4254lhmt
Code:

        #ifdef __has_include
         #if !__has_include("libdrm/drm_fourcc.h")
          #error "Header 'libdrm/drm_fourcc.h' could not be found"
         #endif
        #else
         #include <libdrm/drm_fourcc.h>
        #endif
-----------
Command line: `gcc /home/vincas/.conan2/p/b/gst-p0d93f0835b072/b/build-release/meson-private/tmp4254lhmt/testfile.c -E -P -m64 -D_FILE_OFFSET_BITS=64 -P -O0` -> 0
Has header "libdrm/drm_fourcc.h" : YES 

While with 1.26.6 it fails:

Running compile:
Working directory:  /home/vincas/.conan2/p/b/gst-p59e9e0461c1ff/b/build-release/meson-private/tmpu6l6gri9
Code:

        #ifdef __has_include
         #if !__has_include("drm_fourcc.h")
          #error "Header 'drm_fourcc.h' could not be found"
         #endif
        #else
         #include <drm_fourcc.h>
        #endif
-----------
Command line: `gcc /home/vincas/.conan2/p/b/gst-p59e9e0461c1ff/b/build-release/meson-private/tmpu6l6gri9/testfile.c -E -P -m64 -D_FILE_OFFSET_BITS=64 -P -O0` -> 1
stderr:
/home/vincas/.conan2/p/b/gst-p59e9e0461c1ff/b/build-release/meson-private/tmpu6l6gri9/testfile.c:4:12: error: #error "Header 'drm_fourcc.h' could not be found"
    4 |           #error "Header 'drm_fourcc.h' could not be found"
      |            ^~~~~
-----------
Has header "drm_fourcc.h" with dependency libdrm: NO 

So 1.24 searched for <libdrm/drm_fourcc.h> while 1.26.6 searches for <drm_fourcc.h>

Maybe it’s GStreamer bug or for some reason Meson behaves differently?

I’ve found this commit: gl: Fix libdrm dependency detection and usage (fe1a7edd) · Commits · GStreamer / gstreamer · GitLab

commit fe1a7edda28819020d62ee9165d811b3ae81fbfe
Author: Nirbheek Chauhan <nirbheek@centricular.com>
Date:   Tue May 28 04:23:01 2024 +0530

    gl: Fix libdrm dependency detection and usage
    
    drm_fourcc.h should be picked up via the pkgconfig dep, not the system
    includedir directly. All this allows it to be picked up consistently
    (via the subproject, for example).
    
    Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6932>

diff --git a/subprojects/gst-plugins-base/ext/gl/meson.build b/subprojects/gst-plugins-base/ext/gl/meson.build
index ad514014e9..2715a37129 100644
--- a/subprojects/gst-plugins-base/ext/gl/meson.build
+++ b/subprojects/gst-plugins-base/ext/gl/meson.build
@@ -114,8 +114,8 @@ if bcm_host_dep.found()
   optional_deps += bcm_host_dep
 endif
 
-if egl_dep.found() and cc.has_header('libdrm/drm_fourcc.h')
-  optional_deps += allocators_dep
+if egl_dep.found() and cc.has_header('drm_fourcc.h', dependencies: libdrm_dep)
+  optional_deps += [allocators_dep, libdrm_dep]
 endif
 
 if ['darwin', 'ios'].contains(host_system)

I guess I have to create libdrm/system Conan package to make it find it..?

There’s libdrm: libdrm - Conan 2.0: C and C++ Open Source Package Manager

But it’s still not enought:

lib/gstreamer-1.0/libgstqmlgl.so: undefined symbol: gst_gl_display_x11_new_with_display

I see that GLX is not found during gst-plugins-base Meson run:

Run-time dependency opengl found: YES system
Run-time dependency glx found: NO (tried pkgconfig)
Run-time dependency egl found: YES system
Has header "EGL/egl.h" with dependency egl: YES 
Has header "EGL/eglext.h" with dependency egl: YES 
Has header "drm_fourcc.h" with dependency libdrm: YES 

From meson log file:

Determining dependency 'glx' with pkg-config executable '/home/vincas/.conan2/p/pkgcocde3afe6d7c52/p/bin/pkgconf'
env[PKG_CONFIG]: /home/vincas/.conan2/p/pkgcocde3afe6d7c52/p/bin/pkgconf
env[PKG_CONFIG_PATH]: /home/vincas/.conan2/p/b/gst-pd0dc595c73959/b/build-release/conan
-----------
Called: `/home/vincas/.conan2/p/pkgcocde3afe6d7c52/p/bin/pkgconf --modversion glx` -> 1
stderr:
Package glx was not found in the pkg-config search path.
Perhaps you should add the directory containing `glx.pc'
to the PKG_CONFIG_PATH environment variable
Package 'glx', required by 'virtual:world', not found
-----------
Run-time dependency glx found: NO (tried pkgconfig)

Fixed by updating Conan pacakge recipe to add libglvnd - Conan 2.0: C and C++ Open Source Package Manager dependency, as by default new Conan + Meson will not find it from the system itself…

Hi VincasD,

As you mention Conan 2, I got interested if this means that you have a full Conan2 compatible solution for building all of GStreamer and plugins (good, bad, ugly) etc. in the more recent versions? Are the recipes available somewhere?

Thanks.

PS. Know that this issue is marked solved but made sense to reply to it for the above.

Yes I have patched Conan’s GStreamer recipes to work with Conan 2 and GStreamer up to 1.26.6 So far it’s only in our local repo. I have not found time to upstream it, as it probably would need even more time to make them “right”… I have some local hacks to use local checkout for bisecting, which should be removed, etc…

I could paste it somewhere I guess, gist, pastebins?