代码之家  ›  专栏  ›  技术社区  ›  wizzup

stdenv。使用cmake的mkDerivation无法静态链接

  •  1
  • wizzup  · 技术社区  · 7 年前

    我正在努力建立 halite default.nix :

    with import <nixpkgs> {};
    
    stdenv.mkDerivation rec {
      pname = "halite";
      version = "git";
      name = "${pname}-${version}";
      src = ./.;
      buildInputs = [ cmake ];
    }
    

    但是当我跑步的时候 nix-build default.nix

    [ 97%] Building CXX object CMakeFiles/halite.dir/main.cpp.o
    [100%] Linking CXX executable halite
    /nix/store/z470j6lybdsy4ql972k392490bprhd2g-binutils-2.28.1/bin/ld: cannot find -lpthread
    /nix/store/z470j6lybdsy4ql972k392490bprhd2g-binutils-2.28.1/bin/ld: cannot find -lm
    /nix/store/z470j6lybdsy4ql972k392490bprhd2g-binutils-2.28.1/bin/ld: cannot find -lc
    collect2: error: ld returned 1 exit status
    

    可以找到完整日志 here

    我试图解决这个问题,但没有成功:

    • gcc , pkgconfig buildInputs
    • nativeBuildInputs propergatedBuildInputs

    违约尼克斯 shell.nix 对于 cmake 项目

    1 回复  |  直到 7 年前
        1
  •  0
  •   wizzup    7 年前

    通过使用解决 glibc.static 作为ppb suggested 谢谢

    事实证明,问题并不是来自 default.nix halite 尝试使用静态链接。

    当我改变时 CMakeList.txt 要使用动态链接,构建很好。