In the man page for ld.so(8), it says that
When resolving library dependencies, the dynamic linker first inspects each dependency string to see if it contains a slash (this can occur if a library pathname containing slashes was specified at link time). If a slash is found, then the dependency string is interpreted as a (relative or absolute) pathname, and the library is loaded using that pathname.
gcc link against a library with a path with a slash? I have tried with
-l but that seems to work only with a library name which it uses to search various paths, not with a path argument itself.
One follow-on question: when linking to a relative path in this way, what is the path relative to (e.g. the directory containing the binary or the working directory at runtime)?
All of the linking guides I find when searching discuss using
RPATH is deprecated and most discussions discourage using
RUNPATH with a path starting with
$ORIGIN allows for a link to a relative path, but it is a little fragile because it can be overridden by
LD_LIBRARY_PATH. I wanted to know if a relative path would be more robust (since I can't find anything discussing this I am guessing not, likely because the path is relative to the runtime directory).