I installed ATLAS (with Netlib LAPACK) in a Docker image, and now every time I run ldconfig, I get the following errors:

ldconfig: Can't link /usr/local/lib//usr/local/lib/libtatlas.so to libtatlas.so
ldconfig: Can't link /usr/local/lib//usr/local/lib/libsatlas.so to libsatlas.so

Of course, /usr/local/lib//usr/local/lib/libtatlas.so doesn't exist, but I'm confused why it would try to look for this file, since libtatlas.so isn't a symbolic link:

root@cd00953552ab:/usr/local/lib# ls -la | grep atlas
-rw-r--r-- 1 root staff 15242054 Apr 27 08:18 libatlas.a
-rwxr-xr-x 1 root staff 17590040 Apr 27 08:18 libatlas.so
-rwxr-xr-x 1 root staff 17492184 Apr 27 08:18 libsatlas.so
-rwxr-xr-x 1 root staff 17590040 Apr 27 08:18 libtatlas.so

Why would this be happening, and is there a way to fix it/turn off this error message?

Edit: Here's the Readelf output:

root@cd00953552ab:/usr/local/lib# eu-readelf -a /usr/local/lib/libatlas.so | grep SONAME
  SONAME            Library soname: [/usr/local/lib/libtatlas.so]

For some reason, probably related to the way the libraries were built (and more specifically, linked), they’ve stored their installation directory in their soname: thus libtatlas.so’s soname is /usr/local/lib/libtatlas.so. ldconfig tries to link libraries to their soname, if it doesn’t exist, in the same directory: it finds /usr/local/lib/libtatlas.so, checks its soname, determines that a link needs to be made from /usr/local/lib//usr/local/lib/libtatlas.so (the directory and soname concatenated) to /usr/local/lib/libtatlas.so, and fails because /usr/local/lib/usr/local/lib doesn’t exist.

The appropriate way to fix this is to ensure that the libraries’ sonames are defined correctly. Typically I’d expect libtatlas.so.3 etc. with no directory name (the version would depend on the ABI level of the library being built). You probably need to rebuild the libraries, or find a correctly-built package...

Alternatively, you can edit a library’s soname using PatchELF:

patchelf --set-soname libtatlas.so /usr/local/lib/libtatlas.so

Ideally you should relink the programs you built using this library, since they’ll have the soname embedded too (you can also patch that using PatchELF).

In an evolving system, you’d really want to specify a version in the soname, but in a container it probably doesn’t matter — you should be rebuilding the container for upgrades anyway.

  • Ah, I see. It doesn't seem to make a difference (I'm able to compile a program that depends on it without issue, although when I run ldd it gives me some kind of weird output) but it is a bit annoying. Is it possible to fix it without rebuilding the libraries? I might need to use the Debian package/source rather than the original, since the original seems to have these issues and the Debian package doesn't.
    – josh
    Apr 27 '17 at 9:41
  • It turns out you can fix this with PatchELF, see my update. Apr 27 '17 at 10:59

In this particular case of BLAS library ATLAS. The fix to the real cause is to correct the makefile used to build the package.

See answer of @Stephen Kitt for the reasoning.

However, due to a bug of --set-soname in patchelf, the patchelf solution cannot work.

Your library path contains '/usr/local', so I assume it is building from source code.

Check the file $(SRC)/makes/Make.lib, where $(SRC) is your source code root directory.

Particularly these lines:

    $(LD) $(LDFLAGS) -shared -soname $(LIBINSTdir)/$(outso) -o $(outso) \
       -rpath-link $(LIBINSTdir)  \
       --whole-archive $(libas) --no-whole-archive $(LIBS)

The soname is improper here: -soname $(LIBINSTdir)/$(outso). Change it to -soname $(outso), then rebuild the library will fix this problem.

In case you already have a success build, change corresponding line in $(BUILD)/lib/Makefile, where $(BUILD) is the directory for building the library. Then make shared to build the libraries.

Use command such as readelf -d libtatlas.so | grep soname to check the soname in the resulting .so file. It should not contain any directory part.

If you cannot find the correct makefile (e.g. using a different version of ATLAS), try grep -IR soname to locate the spot that need to modify.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.