Hey guys, i could use some help.

I am trying to build cuprate: https://github.com/Cuprate/cuprate/ with the instructions found in https://github.com/Cuprate/cuprate/pull/728/changes/48ee1bb9ed2dc3a0d7b53f66bb48f6273c964a26

It builds fine, but when attempting to run it i get

[nix-shell:~/build/cuprate/cuprate/target/release]$ ./cuprated -h

./cuprated: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory


[nix-shell:~/build/cuprate/cuprate/target/release]$
  • moonpiedumplings@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    29 days ago

    Okay, this is going to depend on whether or not you are on Nixos.

    If you are not on NixOS, then this shell.nix works for me, although you will need libstdc++ installed on your host. Also, I cut out some of the packages, because the default nix shell provides ldd and gcc already, so there is no need to specifically include them.

    { pkgs ? import <nixpkgs> {} }:
    
    let packages = [
      pkgs.cargo
      pkgs.cmake		# Cmake
      pkgs.git		# Git version control system
      pkgs.pkg-config    # often needed for C dependencies
      pkgs.rustc          # Nix’s rustc (matches the store layout)
      pkgs.libcxx
      pkgs.gccNGPackages_15.libstdcxx
    ];
    
    in
    
    pkgs.mkShell {
      nativeBuildInputs = packages;
    
      LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages;
    
      # Optional – tell Rust to prefer lld for Rust‑only code, but fall back to gcc
      # for build‑script / C‑linking steps.
      RUSTFLAGS = "-C link-arg=-fuse-ld=lld -C link-arg=-Wl,-rpath,/usr/lib -C link-arg=-Wl,-dynamic-linker,/lib64/ld-linux-x86-64.so.2";
      RUST_BACKTRACE = 1;
    }
    

    But if you are on NixOS, then things get a bit different. NixOS won’t put some of the stuff that the rust compiler is expecting to be there by default, but not there. For the NixOS version, remove this part -C link-arg=-Wl,-dynamic-linker,/lib64/ld-linux-x86-64.so.2 from RUSTFLAGS.

    You will probably have to either run it from the shell, or create a nix package for it.