3

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?

kylehutson
  • 31
  • 1
  • How can you link against symbolic link? `:)` – Alexander Shukaev Apr 18 '13 at 18:27
  • 1
    Complain to your distribution that those various libraries should have SONAME libopenblas.so? – Marc Glisse Apr 18 '13 at 19:09
  • Does your library take so long to compile that you cannot recompile it for each architecture? That would be the most idea solution. – Ian Stapleton Cordasco Apr 18 '13 at 20:01
  • sigmavirus24 - I'm submitting a job via Sun Grid Engine to run on the cluster, and I don't know which architecture it will be running on. I have an R script that's calling my compiled .so, so I would need to know in advance which architecture it's running on. Here are the kludges I'm working on: 1) Compiling for each arch, then detecting the arch and calling the correct .so within R 2) Compiling at run-time (e.g., bash script runs GCC and then runs the R script) 3) Trying a different C BLAS library – kylehutson Apr 18 '13 at 20:06
  • I think this has already been answered here: http://stackoverflow.com/questions/6339399/gcc-link-shared-library-against-symbolic-link – Ryan Edwards Apr 23 '13 at 18:27
  • 1
    Not quite, Ryan. I had looked at that link, but the solution is "when you build the shared libraries ..." I'm not trying to build any libraries, only use them. – kylehutson Apr 24 '13 at 19:52

0 Answers0