# vtk shared library lookup on linux

**URL:** https://discourse.vtk.org/t/vtk-shared-library-lookup-on-linux/5997
**Category:** Support
**Created:** [June 14, 2021, 7:23pm UTC](https://discourse.vtk.org/t/vtk-shared-library-lookup-on-linux/5997 "2021-06-14T19:23:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Harald\_Scheirich](https://discourse.vtk.org/user_avatar/discourse.vtk.org/harald_scheirich/32/3552_2.png) [@Harald\_Scheirich](https://discourse.vtk.org/u/Harald_Scheirich)
#### Post date: [June 14, 2021, 7:23pm UTC](https://discourse.vtk.org/t/vtk-shared-library-lookup-on-linux/5997/1 "2021-06-14T19:23:05Z")

</div>

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

```auto
        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

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 14, 2021, 7:45pm UTC](https://discourse.vtk.org/t/vtk-shared-library-lookup-on-linux/5997/2 "2021-06-14T19:45:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Harald\_Scheirich](https://discourse.vtk.org/user_avatar/discourse.vtk.org/harald_scheirich/32/3552_2.png) [@Harald\_Scheirich](https://discourse.vtk.org/u/Harald_Scheirich)
#### Post date: [June 14, 2021, 8:06pm UTC](https://discourse.vtk.org/t/vtk-shared-library-lookup-on-linux/5997/3 "2021-06-14T20:06:45Z")

</div>

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

e.g.

```auto
       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

```auto
      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 …

```auto
       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:

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 14, 2021, 8:10pm UTC](https://discourse.vtk.org/t/vtk-shared-library-lookup-on-linux/5997/4 "2021-06-14T20:10:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Harald\_Scheirich](https://discourse.vtk.org/user_avatar/discourse.vtk.org/harald_scheirich/32/3552_2.png) [@Harald\_Scheirich](https://discourse.vtk.org/u/Harald_Scheirich)
#### Post date: [June 14, 2021, 8:28pm UTC](https://discourse.vtk.org/t/vtk-shared-library-lookup-on-linux/5997/5 "2021-06-14T20:28:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Harald\_Scheirich](https://discourse.vtk.org/user_avatar/discourse.vtk.org/harald_scheirich/32/3552_2.png) [@Harald\_Scheirich](https://discourse.vtk.org/u/Harald_Scheirich)
#### Post date: [June 15, 2021, 1:18pm UTC](https://discourse.vtk.org/t/vtk-shared-library-lookup-on-linux/5997/6 "2021-06-15T13:18:13Z")

</div>

That did the trick, thanks !
