I am trying to set up a reproducible C++ development environment with nix-shell for an existing project, and I have run into build issues even though the clang versions in and outside of the nix environment should match. The first issue was compiler warnings, which I was able to resolve by adding the appropriate -Wno-
compiler flag.
Now I am stuck on a linker error. The linker is complaining about multiple definitions of __cxa_throw
, one in libstdc++.a(eh_throw.o)
in the nix store, the other in one of my project files. It’s entirely possible that the project is doing something funny that it should not be doing, but why is this only an issue in the nix shell?
Unfortunately, the build system is so complex that I have been unable to come up with a minimal reproduction of the build errors only occurring under the nix shell, so I instead have to ask for general advice on what to look for, and why clang from the llvm.org Ubuntu packages behaves differently to the corresponding version from nixpkgs?
Finally, is this even the best approach for what I am trying to achieve? I have a shell.nix
with just this:
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/refs/tags/22.05.zip") {};
in pkgs.mkShell {
packages = [
clang_13
ninja
# etc.
];