Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to xcb_get_setup when using SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS #12244

Open
Gpinchon opened this issue Feb 10, 2025 · 9 comments
Milestone

Comments

@Gpinchon
Copy link

Gpinchon commented Feb 10, 2025

Issue

When trying to build SDL2 manually, when using SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS linking fails with undefined reference to xcb_get_setup and /lib/x86_64-linux-gnu/libxcb.so.1: error adding symbols: DSO missing from command line.
It seems like the linker attempts to link with libxcb.so instead of libxcb.a

Build options

option(SDL_SHARED "" OFF)
option(SDL_STATIC "" ON)
option(SDL2_DISABLE_SDL2MAIN  "" ON) # gets ignored by build script
option(SDL2_DISABLE_UNINSTALL "" ON) # ignored
option(SDL2_DISABLE_INSTALL   "" ON) # ignored as well
option(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS "" ON)

System specs

OS : Ubuntu on WSL2
Compiler : Clang 18.1.3
ToolChain : GNU
Git tag : release-2.32.0

I feel like this is linked to #12243

@slouken slouken added this to the 3.x milestone Feb 10, 2025
@Gpinchon
Copy link
Author

Gpinchon commented Feb 10, 2025

Small update : I ended up switching to OpenSUSE-TumbleWeed so I can't really test this any further, but it seems to work better on there. It might be related to the way libX11-devel is handled.

On OpenSUSE you get libX11.so and libXext.so wherease on Ubuntu you get a bunch of static libraries with seemingly missing dependencies. This could also be caused by FindX11.cmake that seems to consider XCB an optional dependency when it's not anymore.

Manually adding xcb to link flags seems to do the trick but I'm unsure as to how to handle this properly. Here is how I did it for now :

#check if we need to add xcb dependencies
check_library_exists("${X11_LIBRARIES}" "xcb_get_setup" "${X11_LIBRARY_DIR}" X11_SOLO)
if (NOT X11_SOLO)
  set(X11_LIBRARIES ${X11_LIBRARIES} xcb)
endif (NOT X11_SOLO)

@madebr
Copy link
Contributor

madebr commented Feb 10, 2025

It seems like the linker attempts to link with libxcb.so instead of libxcb.a

Why do you need a static libxcb.a?
Are you trying to link to all-static X11 libraries?

@Gpinchon
Copy link
Author

Why do you need a static libxcb.a? Are you trying to link to all-static X11 libraries?

Nah, I was just making suppositions as to how it was handled. It seems like libxcb.a has missing symbols too on Ubuntu anyway (I was very confused trying to figure it out)

@madebr
Copy link
Contributor

madebr commented Feb 10, 2025

Ubuntu should just work out of the box, even when used on WSL2.
You just have to make sure all development libraries are installed.

@madebr
Copy link
Contributor

madebr commented Feb 10, 2025

Defining SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS yourself, and expecting SDL3 to build/link is not supported.
By defining that variable, you're effectively bypassing our CMake checks.
As a result, linking fails because we don't provide the required dependencies.

@Gpinchon
Copy link
Author

Gpinchon commented Feb 11, 2025

Defining SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS yourself, and expecting SDL3 to build/link is not supported. By defining that variable, you're effectively bypassing our CMake checks. As a result, linking fails because we don't provide the required dependencies.

Thing is without this define compilation fails on Ubuntu through WSL, the compiler complaining about redefinition of XGenericEventCookie (see #12243)

@Gpinchon
Copy link
Author

Ubuntu should just work out of the box, even when used on WSL2. You just have to make sure all development libraries are installed.

I had difficulties figuring out the required dev libraries, is there an exhaustive list of them in the doc somewhere?

@madebr
Copy link
Contributor

madebr commented Feb 11, 2025

Ubuntu should just work out of the box, even when used on WSL2. You just have to make sure all development libraries are installed.

I had difficulties figuring out the required dev libraries, is there an exhaustive list of them in the doc somewhere?

See https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md#build-dependencies

@Gpinchon
Copy link
Author

Gpinchon commented Feb 11, 2025

See https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md#build-dependencies

Oh thank you very much! I wandered aimlessly in the Wiki located here, and I just found out it was linked inside the Installation section when I was expecting a Build section instead since SDL is already available for installation on most linux/unix based systems through the standard repositories...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants