I have the following Nix derivation:

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 ];

Strangely, when running nix-build scipoptsuite.nix, some files are compiling just fine but then I get:

/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

The bad command is:

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

Does anybody have an idea why this error occurs?

  • 1
    Is it by any chance trying to link things statically? – ppb Jun 14 '17 at 15:34
  • Did you try checking from where this is called? e.g. by adding preBuild = "set -x" to the mkDerivation arguments, to bring bash to dump all its executed commands from before the build. – Profpatsch Jun 24 '17 at 22:53
  • Yes, in the command above the -static option is used. Why is this a problem? – dotlambda Jun 25 '17 at 9:51
  • Instead of preBuild = "set -x", I had to use a makeFlagsArray. See the question for the command that is executed. – dotlambda Jun 25 '17 at 9:53

Most packages in nixpkgs don't have static libraries by default. You need to add glibc.static to build inputs to get static -lc, for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.