I can't get clang++ to work, and I don't know which package I am missing

Hello,

I tried to get clang++ to work, but it fails on each compile. More specifically, I get error messages like these when compiling any C++ program:

nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: cannot find -lc++: No such file or directory
/nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: cannot find -lc++abi: No such file or directory
/nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: cannot find -lc++: No such file or directory
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
/nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: cannot find -lc++abi: No such file or directory
/nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: cannot find -lc++: No such file or directory
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

I have the following section in my configuration.nix:

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
       # other packages
       # ....

     llvmPackages_13.stdenv
     llvmPackages_13.llvm
     llvmPackages_13.libllvm
     llvmPackages_13.libllvm.dev
     llvmPackages_13.libcxxClang
     llvmPackages_13.libcxx
     llvmPackages_13.libcxxabi
     llvmPackages_13.libcxx.dev
     llvmPackages_13.libcxxabi.dev
     llvmPackages_13.libcxxStdenv
     llvmPackages_13.compiler-rt-libc
     llvmPackages_13.clangUseLLVM
     llvmPackages_13.bintools
     libstdcxx5
     gnumake


  ];


I had a problem earlier today with clang-config not being present, and one of the maintainers thankfully helped me with the libllvm.dev package for that. I am fairly new to Nix, so I don’t know which other suffixes are necessary, or what / where to look packages up, outside of search.nixos.org. Are there any packages or configuration options I missed? Or are there other resources/tutorial, that are more official, which I could turn to (since the manual doesn’t have a LLVM/clang section, and the wiki page is about building from source, not these package issues)?

With regards,
Hypatia of Sva.

This is not how you install build tools and libraries on NixOS. Please create a dev/nix-shell or a proper nix package for the application you are trying to build.

https://nixos.wiki/wiki/FAQ#I_installed_a_library_but_my_compiler_is_not_finding_it._Why.3F

2 Likes

right, but this is still a valid question. Specifically why does the error occur and which clang package is the right one to use to be able to compile some source with stdlib?

1 Like