ITADN

X11 lib not found

#26ClosedStealthyKamereon 创建于 2024-03-24
Hello, I'm trying to run a program that uses `x11-dl` to interact with X11 but it cannot find it. I have enabled nix-ld with the appropriate libs: ```nix programs.nix-ld.enable = true; programs.nix-ld.libraries = with pkgs; [ openssl xorg.libX11 xorg.libXcursor xorg.libxcb xorg.libXi libxkbcommon libz ]; ``` I also managed to isolate the problem using a dummy program written in Rust: ```rust use x11_dl::xlib; fn main() { let _xlib = xlib::Xlib::open().unwrap(); } ``` And I get the output: ``` [kamereon@nixos:~/test_xlib]$ cargo run Compiling test_xlib v0.1.0 (/home/kamereon/test_xlib) Finished dev [unoptimized + debuginfo] target(s) in 0.19s Running `target/debug/test_xlib` thread 'main' panicked at src/main.rs:4:36: called `Result::unwrap()` on an `Err` value: OpenError { kind: Library, detail: "opening library failed (libX11.so.6: cannot open shared object file: No such file or directory); opening library failed (libX11.so: cannot open shared object file: No such file or directory)" } note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` I have read documentation about dlopen and I believe it should act the same way as having an ELF linked binary but I may be mistaken that's why I open this ticket. I this behaviour expected ? If yes could you tell me how to run a binary with dynamically loaded libraries on Nixos ? The only way I got it to work but it's quite dirty is by setting the `LD_LIBRARY_PATH` to the content of `NIX_LD_LIBRARY_PATH` manually before running `cargo run`.
关闭于 2024-06-15 1 条评论