When I run cmake -GNinja
I get the error /nix/store/vj57s3h2za2qrfccrvc9b6i7s8mw3ndn-binutils-2.41/bin/ld: cannot find /nix/store/r3cfvnc01wssfqhp5kg8725v94idkysy-clang-18.1.3/lib/clang/18/lib/linux/libclang_rt.asan_static-x86_64.a
This library is located in a different folder: /nix/store/fsr8f5nh12w34dwqs7wcwqdlk40xvcmx-compiler-rt-libc-18.1.3/lib/linux
I tried setting the LIBRARY_PATH and LD_LIBRARY_PATH, but Clang keeps trying to find the libclang_rt library in the clang/ package, rather than it’s actual location in the compiler-rt-libc package.
Note that this command executes as part of the Test C Compiler step, which happens when I use the project
command in my CMakeLists.txt file.
For those interested the Nix packages I downloaded, here is my flake.nix file:
{
description = "A template for Nix based C++ project setup.";
inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs/unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }: {
defaultPackage.x86_64-linux =
# Notice the reference to nixpkgs here.
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
name = "hello";
src = self;
phases = ["buildPhase"];
buildInputs = [
llvmPackages_18.clang-unwrapped
llvmPackages_18.compiler-rt-libc
cmake
ninja
cowsay
abseil-cpp
xgboost
gbenchmark
libhv
prometheus-cpp
simdjson
zlib
# Development time dependencies
gtest
];
shellHook = let
CXX = "clang++-18";
CC = "clang-18";
CMAKE_BUILD_TYPE = "Debug";
in ''
export CXX="${CXX}"
export CC="${CC}"
export CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
export LD_LIBRARY_PATH=${pkgs.llvmPackages_18.compiler-rt-libc}/lib/linux
export LIBRARY_PATH=${pkgs.llvmPackages_18.compiler-rt-libc}/lib/linux
'';
};
};
}