This is Ubuntu 20.04.2 LTS / x86_64 / gcc 9.3.0 here.
When I build the “VTK-9.0.3”, all its shared libraries get the “RUNPATH” pointing to the "/.../build/lib" directory.
However, the “make install” resets the runtime path of all installed “/.../lib/libvtk*.so” shared libraries to "".
Could you, please, consider changing this behavior so that the “RUNPATH” of “installed” shared libraries would be set to "$ORIGIN".
Note: the python related “site-packages/vtkmodules/vtk*.so” already get the runtime path "$ORIGIN/../../../" and also the executables “bin/vtk*” get "$ORIGIN/../lib".
Why would you need rpath to be set on installed libraries? I’ve only seen rpath with $ORIGIN when a program is bundled with its libraries so that it can be unpacked anywhere in the hierarchy.
Yes, that’s more or less my case.
I’d like to “dlopen” VTK shared libraries from a running application, and I would like to spare myself the trouble of maintaining “LD_LIBRARY_PATH”.
Yes, I know I can use: cmake -DCMAKE_INSTALL_RPATH="\$ORIGIN"
However, I am more thinking about the default VTK behavior.
So that, when one tries to use this software compiled by somebody else, one will not need to fight with this “problem”.
An additional quirk of manually setting such a “CMAKE_INSTALL_RPATH” is that, the installed “/.../lib/libvtk*.so” shared libraries get "$ORIGIN" but simultaneously, the python related “site-packages/vtkmodules/vtk*.so” get "$ORIGIN:$ORIGIN/../../../" and also the executables “bin/vtk*” get "$ORIGIN:$ORIGIN/../lib".
how should this work with libraries like libTBB.so?
for building vtk its not a problem, but with something donstream uses vtk (vtl built with TBB). the downstream can’t find the TBB library.
I tried setting CMAKE_INSTALL_RPATH for TBB and VTK to the install/lib directories. things still only work when I set LD_LIBRARY_PATH to the TBB lib directory.
Setting up rpath entries for external libraries is very dependent on the deployment setup. Packaging systems like Spack, Anaconda, or vcpkg already have ways to have packages find their dependencies. For custom builds, it’ll need to be figured out. The “easy way” is to just tell CMake to use the build rpath for the install rpath too with CMAKE_INSTALL_RPATH_USE_LINK_PATH. This only works if nothing will move after installation happens.