Skip to content

Conversation

@to-miz
Copy link
Contributor

@to-miz to-miz commented Nov 30, 2025

This implements dynamic loading of the xcb library through the dl feature flag and dynamic loading of xlib through the xlib_xcb_dl feature flag.

When xlib_xcb_dl is specified x11-dl is used instead of x11, which is why I used another feature flag. It is possible to specify both xlib_xcb and xlib_xcb_dl, in which case xlib_xcb_dl has precedence. This means that cargo test --all-features will always test with dynamic loading.

Loading of the libraries is mostly analogous to how x11-dl does it, with minor changes to error reporting and the usage of OnceLock instead of OnceCell.

For the user of this crate dynamic loading is mostly invisible, since loading of the library is bound to the connection. It only currently gets messy in the opengl_window example, where I needed to support both dynamic loading and dynamic linking for xlib and glx due to being able to support cargo test --all-features in addition to it's default required features.

Closes #88

@rtbo
Copy link
Collaborator

rtbo commented Jan 3, 2026

Hi, thanks a lot. this is a long time needed feature.
I've brought a few fixes and simplifications

@rtbo rtbo merged commit f515cd8 into rust-x-bindings:main Jan 3, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

Support loading libxcb.so and friends through dlopen

2 participants