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

Hi everyone,

I am building VTK 9.1 for Java for few platforms as I could not find VTK java build on CDash (I hope I am not wrong). I make this open and available for download to anyone.

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!

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

2 Likes

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.

1 Like