I would like to hard code the path to a library in my executable, in Linux. On OS X this is achieved by providing the full path after the -o argument when building the library. For example, I build a library like this on OS X:
cc foo.c --shared -o /home/sander/libfoo.so
When I build an executable called 'bar' that links with this library, and I use otool -L on the executable, I get this output:
bar:
/home/sander/libfoo.so (compatibility version 0.0.0, current version 0.0.0)
I can now run this executable from anywhere, and it is always able to find the library.
I am looking for equivalent functionality on Linux with gcc. I'd rather not use rpath since that doesn't link to a specific library + path.