cling::DynamicLibraryManager::loadLibrary severely broken

I have found a brutal fix that may be of interest to other people.

It works on Linux for shared libraries in the default ELF format (I do not know any fix for macOS and / or Windows, sorry).

The trick is to add “$ORIGIN” to their “RUNPATH”.

After building the VTK software and executing “make install”, I have around 160 shared libraries in a single directory ("/.../VTK-9.0/lib" in my previous posts here). By default, these libraries do not have any “RUNPATH” set, so I could simply execute:

patchelf --set-rpath "\$ORIGIN" *.so

Note: the above command unconditionally sets the new “RUNPATH” so one should first make sure that it is really empty:

readelf -d *.so | egrep "File:|RPATH|RUNPATH"

If for “libSomeLibrary.so” one sees some non-empty “old_value” then for this library one should execute:

patchelf --set-rpath "old_value:\$ORIGIN" libSomeLibrary.so