Assuming an ELF platform, if you can rebuild foo.so:
- the best fix is to simply name it libfoo.so
- the next best fix is to set SONAME on it:
gcc -Wl,-soname,foo.so -o foo.so foo.o
when you later link with:
gcc -o a.out a.o /path/to/foo.so
only the SONAME will be recorded as a dependency, not a full /path/to/foo.so.
If you can't rebuild foo.so, then do this:
rm -f foo.so && ln -s /path/to/foo.so foo.so &&
gcc -o a.out a.o ./foo.so && rm -f foo.so