Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 946057 - media-video/obs-studio-31.0.0-r1 fails to compile: ld: libobs.so.30: undefined reference to XDefaultScreen
Summary: media-video/obs-studio-31.0.0-r1 fails to compile: ld: libobs.so.30: undefine...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Chiitoo
URL:
Whiteboard:
Keywords:
: 946670 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-12-07 17:31 UTC by Agostino Sarubbo
Modified: 2024-12-30 17:38 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,440.81 KB, text/plain)
2024-12-07 17:31 UTC, Agostino Sarubbo
Details
/var/tmp/portage/media-video/obs-studio-31.0.0-r1/temp/build.log (build.log,387.21 KB, text/plain)
2024-12-21 14:03 UTC, mingdao
Details
emerge -pqv '=media-video/obs-studio-31.0.0-r1::gentoo' (emerge.log,312 bytes, text/plain)
2024-12-21 14:03 UTC, mingdao
Details
emerge -pqv '=media-video/obs-studio-31.0.0-r1::gentoo' (emerge--info,6.28 KB, text/plain)
2024-12-21 14:07 UTC, mingdao
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2024-12-07 17:31:38 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: media-video/obs-studio-31.0.0 fails to compile.
Discovered on: amd64 (internal ref: ci)

Info about the issue:
https://wiki.gentoo.org/wiki/Project:Tinderbox/Common_Issues_Helper#CF0014
Comment 1 Agostino Sarubbo gentoo-dev 2024-12-07 17:31:40 UTC
Created attachment 913522 [details]
build.log

build log and emerge --info
Comment 2 Agostino Sarubbo gentoo-dev 2024-12-07 17:31:40 UTC
Error(s) that match a know pattern in addition to what has been reported in the summary:


FAILED: plugins/obs-ffmpeg/ffmpeg-mux/obs-ffmpeg-mux 
FAILED: plugins/obs-x264/obs-x264-test 
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: libobs/libobs.so.30: undefined reference to `XCloseDisplay'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: libobs/libobs.so.30: undefined reference to `XDefaultScreen'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: libobs/libobs.so.30: undefined reference to `XLookupString'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: libobs/libobs.so.30: undefined reference to `XOpenDisplay'
collect2: error: ld returned 1 exit status
Comment 3 Avraham Hollander 2024-12-07 20:30:27 UTC
Same exact issue here. My initial assumption was that the issue was me using FFMpeg 7 or that I have USE="-X" set where possible (Wayland desktop) but apparently not.
Comment 4 Agostino Sarubbo gentoo-dev 2024-12-14 07:48:34 UTC
ci has reproduced this issue with version 31.0.0-r1 - Updating summary.
Comment 5 Chiitoo gentoo-dev 2024-12-19 11:46:08 UTC
(In reply to Avraham Hollander from comment #3)
> Same exact issue here. My initial assumption was that the issue was me using
> FFMpeg 7 or that I have USE="-X" set where possible (Wayland desktop) but
> apparently not.

Do you also have 'media-video/ffmpeg[-opengl]'?

I can re-produce this if I remove 'x11-libs/libX11' forcibly, build 'media-video/ffmpeg' with USE="-X -opengl", then build 'media-video/obs-studio'.

Even though 'media-video/obs-studio' will pull in 'x11-libs/libX11' again, 'libavutil.so.58' is not linked to it, hence the failure.

Looks like there might be some issues with the 'media-video/ffmpeg' ebuild, automagically linking with 'x11-libs/libX11' if it's installed, even with USE="-X" and if 'x11-libs/libX11' is not installed but USE="opengl" it will result into

ERROR: opengl not found.

but I'll need to have a closer look to be sure.
Comment 6 Avraham Hollander 2024-12-19 14:38:13 UTC
(In reply to Chiitoo from comment #5)
> (In reply to Avraham Hollander from comment #3)
> > Same exact issue here. My initial assumption was that the issue was me using
> > FFMpeg 7 or that I have USE="-X" set where possible (Wayland desktop) but
> > apparently not.
> 
> Do you also have 'media-video/ffmpeg[-opengl]'?
> 
> I can re-produce this if I remove 'x11-libs/libX11' forcibly, build
> 'media-video/ffmpeg' with USE="-X -opengl", then build
> 'media-video/obs-studio'.
> 
> Even though 'media-video/obs-studio' will pull in 'x11-libs/libX11' again,
> 'libavutil.so.58' is not linked to it, hence the failure.
> 
> Looks like there might be some issues with the 'media-video/ffmpeg' ebuild,
> automagically linking with 'x11-libs/libX11' if it's installed, even with
> USE="-X" and if 'x11-libs/libX11' is not installed but USE="opengl" it will
> result into
> 
> ERROR: opengl not found.
> 
> but I'll need to have a closer look to be sure.

I do indeed. Enabling it didn't make a difference though. Neither did enabling X.
Comment 7 Chiitoo gentoo-dev 2024-12-19 17:12:38 UTC
*** Bug 946670 has been marked as a duplicate of this bug. ***
Comment 8 Chiitoo gentoo-dev 2024-12-19 17:36:37 UTC
(In reply to Avraham Hollander from comment #6)
> I do indeed. Enabling it didn't make a difference though. Neither did
> enabling X.

Hm, yeah, 'opengl' isn't required per se, I think, it's just that I couldn't build 'ffmpeg' with USE="-X opengl" (if I removed 'libX11' first there's that possible automagic).

Whether or not I enable 'X' and recompile 'ffmpeg' with 'libX11' installed, the issue goes away (that automagic), and I see 'libX11.so.6' again in, for example, 'lddtree /usr/lib64/libavutil.so.58'.

That said, if you enabled 'X', then 'ffmpeg' would have been rebuilt with 'libX11' installed, and I might imagine 'libX11' is pulled in by a lot of other packages as well, even on as much Wayland-only as possible, so maybe there is something else to it though I re-produce the exact same errors the way I tried.
Comment 9 mingdao 2024-12-21 14:03:05 UTC
Created attachment 914614 [details]
/var/tmp/portage/media-video/obs-studio-31.0.0-r1/temp/build.log
Comment 10 mingdao 2024-12-21 14:03:28 UTC
Created attachment 914615 [details]
emerge -pqv '=media-video/obs-studio-31.0.0-r1::gentoo'
Comment 11 mingdao 2024-12-21 14:07:17 UTC
Created attachment 914616 [details]
emerge -pqv '=media-video/obs-studio-31.0.0-r1::gentoo'
Comment 12 Chiitoo gentoo-dev 2024-12-22 21:14:26 UTC
Looks like before the upstream CMake changes, 'libobs' was directly linked to 'libX11', but now, at least for me, only via 'libavutil'... perhaps by luck.  I still don't know why that does not happen elsewhere aside from the CI example here, where 'x11-libs/libX11' was installed /after/ 'media-video/ffmpeg', and in which case depending on 'ffmpeg[X]' would be a solution... though I definitely don't know if that is actually needed by OBS Studio functionally.

In any case, I suppose this may be by upstream design, but someone who is seeing the issue could probably at least try something like

--- libobs/cmake/os-linux.cmake
+++ libobs/cmake/os-linux.cmake
@@ -47,6 +47,7 @@
 target_link_libraries(
   libobs
   PRIVATE
+    X11::X11
     X11::x11-xcb
     xcb::xcb
     LibUUID::LibUUID
Comment 13 Chiitoo gentoo-dev 2024-12-23 14:18:30 UTC
Looks like the automagic I'm seeing comes from USE="vdpau" (thanks to a hint by e-mail correspondent who had looked into ffmpeg more than I), probably from here:

https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/configure#l7381

I've now tested building ffmpeg with USE="-X -opengl -vdpau" and verified I see no 'libX11.so' in 'lddtree /usr/lib64/libavutil.so.58', then added the 'X11::X11' link to 'libobs' and everything seems to be fine.

I suppose I'll take it to upstream and see what they think.
Comment 14 Larry the Git Cow gentoo-dev 2024-12-30 17:38:16 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=06f179962d70c06c3df26d562b16fbdae19c2215

commit 06f179962d70c06c3df26d562b16fbdae19c2215
Author:     Jimi Huotari <chiitoo@gentoo.org>
AuthorDate: 2024-12-30 17:31:13 +0000
Commit:     Jimi Huotari <chiitoo@gentoo.org>
CommitDate: 2024-12-30 17:37:49 +0000

    media-video/obs-studio: fix libX11 linking
    
    Closes: https://bugs.gentoo.org/946057
    Signed-off-by: Jimi Huotari <chiitoo@gentoo.org>

 .../files/obs-studio-31.0.0-libx11-link.patch      |  28 +++
 media-video/obs-studio/obs-studio-31.0.0-r2.ebuild | 277 +++++++++++++++++++++
 2 files changed, 305 insertions(+)