vendredi 16 octobre 2020

How to test shared library with nix?

I have the following derivation:

{ stdenv
, cmake
, python38
, enableCfp ? false
, enableZforp ? false
, enableZFPy ? false
, enableUtilities ? true
, enableExamples ? false
, enableTestingSmall ? true
, enableTestingLarge ? false
, enableSharedLibs ? true
}:

let
  # FIXME: Pretty sure this should use buildPythonPackage or something
  pythonEnv = python38.withPackages (ps: [
    ps.cython
    ps.numpy
  ]);
in
stdenv.mkDerivation rec {
  pname = "zfp";
  version = "0.5.5";
  src = builtins.fetchTarball {
    url = "https://computing.llnl.gov/projects/floating-point-compression/download/zfp-0.5.5.tar.gz";
    sha256 = "1l9skghq2iyj4h4ql9z49rqm07bvins6bff0cg8nmfnhp5inww33";
  };

  doCheck = enableTestingSmall || enableTestingLarge;

  cmakeFlags = []
    ++ stdenv.lib.optional enableCfp "-DBUILD_CFP=ON"
    ++ stdenv.lib.optional enableZforp "-DBUILD_ZFORP=ON"
    ++ stdenv.lib.optional enableZFPy "-DBUILD_ZFPY=ON"
    ++ stdenv.lib.optional (!enableUtilities) "-DBUILD_UTILITIES=OFF" # Default on
    ++ stdenv.lib.optional enableExamples "-DBUILD_EXAMPLES=ON"
    ++ stdenv.lib.optional (!enableTestingSmall) "-DBUILD_TESTING_SMALL=OFF" # Default on
    ++ stdenv.lib.optional enableTestingLarge "-DBUILD_TESTING_LARGE=ON"
    ++ stdenv.lib.optional (!enableSharedLibs) "-DBUILD_SHARED_LIBS=OFF"
    ++ stdenv.lib.optional (!doCheck) "-DBUILD_TESTING=OFF";

  nativeBuildInputs = [ cmake ]
    ++ stdenv.lib.optional enableZFPy pythonEnv;
}

While it generates the correct libraries, testing does not seem to use them. I get:

/build/source/build/nix/store/iay9p2wvwrv3x2352qwk0jhbpkx45ibl-zfp-0.5.5/bin/testzfp: error while loading shared libraries: libzfp.so.0: cannot open shared object file: No such file or directory

How is one supposed to include the generated libraries in the LD_LIBRARY_PATH(?)

Thanks.

Aucun commentaire:

Enregistrer un commentaire