NixOS 上的“ld:找不到 -lc”

NixOS 上的“ld:找不到 -lc”

我有以下 Nix 推导:

with import <nixpkgs> {};

stdenv.mkDerivation rec {
  name = "scipoptsuite-${version}";
  version = "4.0.0";

  src = fetchurl {
    url = "http://scip.zib.de/download/release/scipoptsuite-${version}.tgz";
    sha256 = "087535760eae3d633e2515d942a9b22e1f16332c022be8d093372bdc68e8a661";
  };

  buildInputs = [ zlib gmp readline ];
}

奇怪的是,运行时nix-build scipoptsuite.nix,一些文件编译得很好,但我得到:

/nix/store/x9v0yxy5iybp2m2ccqwqkvxgjy7zrw8f-binutils-2.28/bin/ld: cannot find -lgmp
/nix/store/x9v0yxy5iybp2m2ccqwqkvxgjy7zrw8f-binutils-2.28/bin/ld: cannot find -lm
/nix/store/x9v0yxy5iybp2m2ccqwqkvxgjy7zrw8f-binutils-2.28/bin/ld: cannot find -lz
/nix/store/x9v0yxy5iybp2m2ccqwqkvxgjy7zrw8f-binutils-2.28/bin/ld: cannot find -lc

错误的命令是:

gcc -O3 -m64 -mtune=native obj/O.linux.x86_64.gnu.static.opt/zimpl.o obj/O.linux.x86_64.gnu.static.opt/xlpglue.o obj/O.linux.x86_64.gnu.static.opt/zlpglue.o obj/O.linux.x86_64.gnu.static.opt/ratlpstore.o obj/O.linux.x86_64.gnu.static.opt/ratlpfwrite.o obj/O.linux.x86_64.gnu.static.opt/ratmpswrite.o obj/O.linux.x86_64.gnu.static.opt/ratmstwrite.o obj/O.linux.x86_64.gnu.static.opt/ratordwrite.o obj/O.linux.x86_64.gnu.static.opt/ratpresolve.o -Llib -lzimpl-3.3.4.linux.x86_64.gnu.opt -lgmp -lm -lz -static -o bin/zimpl-3.3.4.linux.x86_64.gnu.static.opt

有人知道为什么会出现这个错误吗?

答案1

nixpkgs 中的大多数包默认没有静态库。例如,您需要添加glibc.static构建输入才能获取 static 。-lc

相关内容