It can be done by setting rpath to origin, even post compilation using the patchelf tool. Works great with C shared libraries. Perhaps ABI issues with C++ shared libs introduces other problems.
With the warning that rpath!=runpath, both are called rpath, and which you get depends on your linker and whether you also pass -Wl,--disable-new-dtags
Runpath is the default, and also the one that is non-transitive and overridden by environment variables.
Runpath is the default, and also the one that is non-transitive and overridden by environment variables.