# Shared libraries can't be redistributed since they refer to their build path

**URL:** https://discourse.vtk.org/t/shared-libraries-cant-be-redistributed-since-they-refer-to-their-build-path/7892
**Category:** Support
**Created:** [February 22, 2022, 5:48pm UTC](https://discourse.vtk.org/t/shared-libraries-cant-be-redistributed-since-they-refer-to-their-build-path/7892 "2022-02-22T17:48:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Martin3d](https://discourse.vtk.org/user_avatar/discourse.vtk.org/martin3d/32/4303_2.png) [@Martin3d](https://discourse.vtk.org/u/Martin3d)
#### Post date: [February 22, 2022, 5:48pm UTC](https://discourse.vtk.org/t/shared-libraries-cant-be-redistributed-since-they-refer-to-their-build-path/7892/1 "2022-02-22T17:48:57Z")

</div>

Hi everyone,

I am building VTK 9.1 for Java for few platforms as I [could not find VTK java build on CDash](https://open.cdash.org/index.php?project=VTK) (I hope I am not wrong). I make this [open and available for download to anyone](http://download.jzy3d.org/vtk/build/9.1.0/).

My problem is that I recently noticed that some of the shared libraries built with CMake hold a reference to the path of my development computer. I hence can’t load them properly despite defining `java.library.path=/path/to/where/vtk/shared/libs/were/downloaded`

When starting a program, I got UnsatisfiedLinkErrors referecing the path where the libraries have been built on my dev computer.

`Reason: tried: '/Users/martin/Dev/jzy3d/external/VTK-9.1.0-build2/lib/libvtkCommonMathJava.jnilib' (no such file), '/Users/martin/Dev/jzy3d/external/VTK-9.1.0-build2/lib/java/vtk-Darwin-x86_64/libvtkCommonMathJava.jnilib' (no such file), '/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/libvtkCommonMathJava.jnilib' (no such file), '/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/server/libvtkCommonMathJava.jnilib' (no such file), '/Users/martin/Dev/jzy3d/external/VTK-9.1.0-build2/lib/libvtkCommonMathJava.jnilib' (no such file), '/Users/martin/Dev/jzy3d/external/VTK-9.1.0-build2/lib/java/vtk-Darwin-x86_64/libvtkCommonMathJava.jnilib' (no such file), '/Library`

The variables `CMAKE_SKIP_INSTALL_RPATH` and `CMAKE_SKIP_RPATH` are unchecked (I understood they should remain unchecked)

Any help on dropping the path of the developer machine in a shared library?

Thanks!

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 22, 2022, 10:18pm UTC](https://discourse.vtk.org/t/shared-libraries-cant-be-redistributed-since-they-refer-to-their-build-path/7892/2 "2022-02-22T22:18:00Z")

</div>

Hello,

I don’t know much about JNI, but I assume you’re on some POSIX system (rpath). Have you tried to add the path where the VTK libraries are to `LD_LIBRARY_PATH` (`DYLD_LIBRARY_PATH` in MacOS)? If your system is not something from Mars, it should search for libraries there before looking in the executable’s `rpath` entries.

regards,

Paulo

---

<div class="post-metadata">

### Author: ![Martin3d](https://discourse.vtk.org/user_avatar/discourse.vtk.org/martin3d/32/4303_2.png) [@Martin3d](https://discourse.vtk.org/u/Martin3d)
#### Post date: [February 28, 2022, 10:10am UTC](https://discourse.vtk.org/t/shared-libraries-cant-be-redistributed-since-they-refer-to-their-build-path/7892/3 "2022-02-28T10:10:21Z")

</div>

Thank you Paulo, referencing the lib path in `DYLD_LIBRARY_PATH` instead of `java.library.path` solves the problem on macOS. For Windows, I could make it work by adding it to `PATH`. I haven’t tried Ubuntu yet, but I think this will work with `LD_LIBRARY_PATH`.
