I would like to hardcode the library path in my Linux executable. On OS X, this is achieved by providing the full path after the -o argument when creating the library. For example, I create such a library on OS X:
cc foo.c
When I create an executable file called "bar" that links to this library, and I use otool -L in the executable, I get this output:
bar:
/home/sander/libfoo.so (compatibility version 0.0.0, current version 0.0.0)
Now I can run this executable from anywhere, and it can always find the library.
I am looking for equivalent functionality on Linux with gcc. I would prefer not to use rpath, as it does not reference a specific library + path.
source
share