[Nix-dev] "Error loading shared libraries" in a temporary tool

Damien Cassou damien at cassou.me
Wed Jul 27 11:23:20 CEST 2016


Vladimír Čunát <vcunat at gmail.com> writes:

> [ Unknown signature status ]
> On 07/25/2016 10:48 AM, Damien Cassou wrote:
>> The vtk compilation chain starts by building a library
>> (libvtksys-7.0.so.1) and a tool (vtkHashSource) that depends on this
>> library. Later, the compilation chain uses the tool but this results in
>> an error:
>
> I typically work around such issues by setting LD_LIBRARY_PATH in the
> builder (that only affects environment during the build).

Thanks. It still doesn't work though. I tried:

    preBuild = ''
      LD_LIBRARY_PATH="$(pwd)/lib:$LD_LIBRARY_PATH";
      echo =============================================================
      echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
      echo =============================================================
    '';

but it didn't work:

    $ nix-build -K -A vtk
    =============================================================
    LD_LIBRARY_PATH=/tmp/nix-build-vtk-7.0.0.drv-0/VTK-7.0.0/build/lib:
    =============================================================
    [...]
    [ 47%] Generating vtkSocketCommunicatorHash.h
    ../../bin/vtkHashSource-7.0: error while loading shared libraries:
    libvtksys-7.0.so.1: cannot open shared object file: No such file or
    directory

    $ sudo ls -l /tmp/nix-build-vtk-7.0.0.drv-0/VTK-7.0.0/build/lib | grep libvtksys-7
    lrwxrwxrwx 1 nixbld1 nixbld      18 27 juil. 10:59 libvtksys-7.0.so -> libvtksys-7.0.so.1
    -rwxr-xr-x 1 nixbld1 nixbld  375624 27 juil. 10:59 libvtksys-7.0.so.1

Please note that the existing derivation contains this code that I don't
understand:

    # Shared libraries don't work, because of rpath troubles with the current
    # nixpkgs camke approach. It wants to call a binary at build time, just
    # built and requiring one of the shared objects.
    # At least, we use -fPIC for other packages to be able to use this in shared
    # objects.
    cmakeFlags = [ "-DCMAKE_C_FLAGS=-fPIC" "-DCMAKE_CXX_FLAGS=-fPIC" ]
      ++ optional (qtLib != null) [ "-DVTK_USE_QT:BOOL=ON" ];

Thanks

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill


More information about the nix-dev mailing list