vtk shared library lookup on linux

iMSTK depends on vtk for some part of its functionality, i recently rearranged the unit tests (that are utilizing) google test to link to gtest_main rather than the binary produced via create_test_sourcelist in CMAKE, but in doing so managed to break the shared library lookup which means that some tests won’t execute when built for the dashboard. I’ve tried various ways of setting either LD_LIBRARY_PATH from cmake all without success even though setting it in the shell makes the tests execute correctly.

The odd part is that ldd reports that some of the vtk libraries are actually found while others aren’t here is an excerpt

        linux-vdso.so.1 (0x00007fffdfad6000)
        libg3logger.so => /mnt/c/Work/projects/imstk/build-linux/install/lib/libg3logger.so (0x00007f6b5ebfc000)
        libtbb.so => /mnt/c/Work/projects/imstk/build-linux/install/lib/libtbb.so (0x00007f6b5ebb5000)
        libvtkFiltersSources-9.0.so.1 => /mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkFiltersSources-9.0.so.1 (0x00007f6b5eb03000)
        libvtkFiltersGeneral-9.0.so.1 => /mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkFiltersGeneral-9.0.so.1 (0x00007f6b5e7c6000)
        libvtkFiltersCore-9.0.so.1 => /mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkFiltersCore-9.0.so.1 (0x00007f6b5e270000)
        libvtkCommonExecutionModel-9.0.so.1 => /mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkCommonExecutionModel-9.0.so.1 (0x00007f6b5e19c000)
        libvtkCommonDataModel-9.0.so.1 => /mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkCommonDataModel-9.0.so.1 (0x00007f6b5dd65000)
        libvtkCommonTransforms-9.0.so.1 => /mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkCommonTransforms-9.0.so.1 (0x00007f6b5dd32000)
        libvtkCommonCore-9.0.so.1 => /mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkCommonCore-9.0.so.1 (0x00007f6b5d8b3000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f6b5d6c0000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6b5d571000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6b5d540000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6b5d51d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6b5d320000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f6b5ee19000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f6b5d310000)
        libvtkCommonComputationalGeometry-9.0.so.1 => not found
        libvtkCommonMisc-9.0.so.1 => not found
        libvtkCommonMath-9.0.so.1 => not found
        libvtkCommonMisc-9.0.so.1 => not found
        libvtkCommonMath-9.0.so.1 => not found
        libvtkCommonSystem-9.0.so.1 => not found
        libvtkCommonMisc-9.0.so.1 => not found
        libvtksys-9.0.so.1 => not found
        libvtkCommonMisc-9.0.so.1 => not found
        libvtkCommonSystem-9.0.so.1 => not found
        libvtkCommonMath-9.0.so.1 => not found
        libvtksys-9.0.so.1 => not found
        libvtkCommonMath-9.0.so.1 => not found
        libvtksys-9.0.so.1 => not found
        libvtkloguru-9.0.so.1 => not found

Any help is appreciated, thanks

I would recommend using LD_DEBUG=libs in the environment to have the runtime loader log the library lookup procedure.

Thanks, setting that reports that the vtk libraries that it’s finding are found via RUNPATH

e.g.

       411:     find library=libvtkCommonCore-9.0.so.1 [0]; searching
       411:      search path=/mnt/c/Work/projects/imstk/build-linux/install/lib         (RUNPATH from file install/bin/GeometryTests)
       411:       trying file=/mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkCommonCore-9.0.so.1

whereas the missing ones just don’t

      411:     find library=libvtkCommonComputationalGeometry-9.0.so.1 [0]; searching
       411:      search cache=/etc/ld.so.cache
       411:      search path=/lib/x86_64-linux-gnu/tls/haswell/x86_64:/lib/x86_64-linux-gnu/tls/haswell:/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/haswell/x86_64:/lib/x86_64-linux-gnu/haswell:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64:/usr/lib/x86_64-linux-gnu/tls/haswell:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/haswell/x86_64:/usr/lib/x86_64-linux-gnu/haswell:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu:/lib/tls/haswell/x86_64:/lib/tls/haswell:/lib/tls/x86_64:/lib/tls:/lib/haswell/x86_64:/lib/haswell:/lib/x86_64:/lib:/usr/lib/tls/haswell/x86_64:/usr/lib/tls/haswell:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/haswell/x86_64:/usr/lib/haswell:/usr/lib/x86_64:/usr/lib           (system search path)
       411:       trying file=/lib/x86_64-linux-gnu/tls/haswell/x86_64/libvtkCommonComputationalGeometry-9.0.so.1
       411:       trying file=/lib/x86_64-linux-gnu/tls/haswell/libvtkCommonComputationalGeometry-9.0.so.1
       411:       trying file=/lib/x86_64-linux-gnu/tls/x86_64/libvtkCommonComputationalGeometry-9.0.so.1
... 

and when i set LD_LIBRARY_PATH i get this result …

       493:     find library=libvtkCommonComputationalGeometry-9.0.so.1 [0]; searching
       493:      search path=/mnt/c/Work/projects/imstk/build-linux/install/lib         (RUNPATH from file install/bin/GeometryTests)
       493:       trying file=/mnt/c/Work/projects/imstk/build-linux/install/lib/libvtkCommonComputationalGeometry-9.0.so.1
       493:

Ah, the not-found ones are transitive. Your VTK needs an install rpath of $ORIGIN set.

So that’s setting set (CMAKE_INSTALL_RPATH $Origin/../lib) for the vtk that we are building i’ll give that a shot, thanks

That did the trick, thanks !

1 Like