Background:
I wrote a program that uses the OpenBLAS libraries for a very heterogeneous compute cluster. OpenBLAS uses different libraries for different architectures.
So on one machine 'ls -l /usr/lib64/libopenblas.so' results in
lrwxrwxrwx 1 root root 31 Mar 6 15:13 /usr/lib64/libopenblas.so -> libopenblas_barcelona-r0.2.6.so*
On another, the result is
lrwxrwxrwx 1 root root 33 Mar 4 09:43 /usr/lib64/libopenblas.so -> libopenblas_sandybridge-r0.2.6.so*
There may be others, but these are the two I have checked. Both implement the same API, just use different optimizations.
The problem:
When I compile my own shared object file using these I use
gcc ... -lopenblas
and it compiles just fine, and it runs on machines with similar architecture (i.e., those with 'libopenblas_barcelona-r0.2.6.so'), but on other architectures it fails to run.
ldd shows that it links against libopenblas_barcelona-r0.2.6.so rather than libopenblas.so.
Is there any way I can tell gcc to link against the symlink, rather than the result of that symlink, so that it will be "right" regardless of the architecture of the machine it's running on?