rust-in-action / code

Source code for the book Rust in Action
https://www.manning.com/books/rust-in-action?a_aid=rust&a_bid=0367c58f&chan=github
1.9k stars 445 forks source link

ch6/ch6-particles fails with missing libX11.so.6 #113

Open t-taylor opened 1 year ago

t-taylor commented 1 year ago

After executing cargo run I get the following error:

thread 'main' panicked at 'Failed to initialize any backend! Wayland status: NoWaylandLib X11 status: LibraryOpenError(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)" })', /home/tom/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.6/src/platform_impl/linux/mod.rs:757:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

As well as the first set of benchmark statements.

running on nixos with hyprland wayland window manager.

t-taylor commented 1 year ago

The solution for me was to run in a nix-shell with the following shell.nix

{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
  buildInputs = with pkgs; [cargo];
  shellHook = ''
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${
      with pkgs;
        lib.makeLibraryPath [
          libGL
          xorg.libX11
          xorg.libXi
          xorg.libXcursor
          xorg.libXrandr
        ]
    }"
  '';
}