12

I was just on vacation for a month so am unable to say the exact point at which this happened, but R from the official Arch repos is now unable to start, citing

/usr/lib64/R/bin/exec/R: error while loading shared libraries: 
libgfortran.so.3: cannot open shared object file: No such file or directory

I thought that perhaps a symlink was improperly placed or destroyed, so I looked in /usr/lib to try to find it:

ls -halt /usr/lib/libgfortran.so.*

lrwxrwxrwx 1 root root   20 May 16 03:01 /usr/lib/libgfortran.so.4 -> libgfortran.so.4.0.0
-rwxr-xr-x 1 root root 7.1M May 16 03:01 /usr/lib/libgfortran.so.4.0.0

Has libfortran.so.3 been superseded by libgfortran.so.4 in Arch? If so, are there any possible workarounds for getting R to run with an older version?


pacman -Qi r

Name            : r
Version         : 3.4.0-2
Description     : Language and environment for statistical computing and graphics
Architecture    : x86_64
URL             : http://www.r-project.org/
Licenses        : GPL
Groups          : None
Provides        : None
Depends On      : blas  lapack  bzip2  libpng  libjpeg  libtiff  ncurses  pcre  readline  zlib  perl  gcc-libs  libxt  libxmu  pango  xz  desktop-file-utils  zip  unzip
Optional Deps   : tk: tcl/tk interface [installed]
                  texlive-bin: latex sty files [installed]
Required By     : None
Optional For    : graphviz
Conflicts With  : None
Replaces        : None
Installed Size  : 58.04 MiB
Packager        : Evangelos Foutras <evangelos@foutrelis.com>
Build Date      : Tue 25 Apr 2017 05:04:31 AM EDT
Install Date    : Tue 20 Jun 2017 12:27:06 PM EDT
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

Edit: If anyone else comes across this, the r-devel AUR correctly compiles and runs, so hopefully on the next version bump the issue will be resolved.

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Chris C
  • 1,625
  • 1
  • 19
  • 22

6 Answers6

8

Indeed, gfortran 7 bumps the ligfortran version to version 4. See http://gcc.1065356.n8.nabble.com/patch-fortran-PR77828-Linking-gfortran-7-compiled-program-with-libgfortran-of-5-x-allowed-but-crashes-td1311625.html It is not backwards compatible and some APIs have changed.

If you install an older version of gfortran you will get libgfortran.so.3. It is completely fine to have multiple versions in your system. Maybe there is a way how to rebuild R for version 4, but it will be possibly more work. See other answers how to rebuild the software https://stackoverflow.com/a/50744705/721644

  • Thank you Vladimir, are you aware of any methods for downgrading just gfortran to 6.* without downgrading all of `gcc`? The usual method (installing a cached version of the package from `pacman`) is unfortunately a no-go, as it requires an identical version of `gcc` and I'm not willing to bust the rest of my system. – Chris C Jun 20 '17 at 19:38
  • 1
    Do not downgrade, it is not a good idea. Install additional version of GCC. – Vladimir F Героям слава Jun 20 '17 at 20:19
2

I work on a software named pyferret which needs libgfortran.so.3. I am running fedora 27 whose package manager installs gfortran 7 (A higher version) by default. This produces the shared object libgfortran.so.4 in /usr/lib64. Another Linux system running Ubuntu 16.04.3, however has libgfortran.so.3. I copied it to my system in ~/pkgs/libs and ran the application as

export LD_PRELOAD=/home/vasu/pkgs/libs/libgfortran.so.3:/home/vasu/pkgs/libs/libopenblas.so.0;pyferret

This worked without the above error.

srinivasu u
  • 1,393
  • 11
  • 12
  • 1
    A warning, copying a binary from one Linux distribution to another may or may not work depending on many unpredictable factors. But it is good to know it works in this case. – Vladimir F Героям слава Nov 21 '17 at 12:09
  • 1
    Yeah. I agree. It may or may not work. But it worked in my case and the OP can give it a try. I also know building a lower version in a system with higher versions of software is quite difficult. – srinivasu u Nov 21 '17 at 12:14
1

There are many packages in R dependent upon GCC Fortran. Some of those have not been updated to compile against the new GCC, while some package get updated that are dependent upon these, deldir and robustbase are two examples.

Check your warnings and are install any of the packages that fail to load then execute the upgrade.

clemens
  • 16,716
  • 11
  • 50
  • 65
Joe
  • 11
  • 1
1

The problem may come from some AUR packages that haven't been rebuild after the GCC update. In my personal case, it was probably the package openblas-lapack that messed around (see https://bbs.archlinux.org/viewtopic.php?id=236900). So there might be no need to install any former version of GCC.

What I did was to:

  1. update all my AUR packages (yaourt -Syua)
  2. then rebuild R (pacman -S r)

and it worked again.

Ludovic Duvaux
  • 307
  • 2
  • 10
  • Thanks. Why doesn't the distro rebuild the dependent packages? In my answer I assumed this distro must use external binary repositories. If it works like Gentoo than yes, just rebuild the damn software... I wonder why nobody told us the command for rebuilding in a year since I answer. – Vladimir F Героям слава Jun 07 '18 at 16:00
  • I'm no specialist but looks like the Arch people set their convention that way: any package from the official repo will be rebuild, any package from the AUR repo is the responsability of the user. Most of the time it's no big deal to me because I use the `yaourt -Syua` command to upgrade. However, it may sometimes be bothering but I guess they have a pretty good reason to do that way. – Ludovic Duvaux Jun 08 '18 at 15:55
  • @VladimirF I am having this problem in Gentoo, `libgfortran.so.3` is missing, do you know how to solve it? – Alejandro Alcalde Sep 05 '18 at 06:42
  • @elbaulp rebuild your packages against the new GCC – Vladimir F Героям слава Sep 05 '18 at 06:50
  • @VladimirF I followed this (https://wiki.gentoo.org/wiki/Upgrading_GCC) with no success – Alejandro Alcalde Sep 05 '18 at 18:30
  • @elbaulp You must rebuild the software that reports the error and all other libreries like BLAS and similar. Not just GCC. – Vladimir F Героям слава Sep 05 '18 at 21:11
1

This issue periodically occurs whenever libgfortran receives an incompatible soname bump, mostly because in the R world it is quite common for blas/lapack to be replaced by alternative implementations from the AUR.

The important thing to note here is that it is not actually R that has the error.

Minor disclaimer here: I'm speaking with my official Arch Linux bugwrangler hat on here, and this is how I would try to track down this sort of issue. (It's also how I check whether a bug report should be closed as invalid.)

Using my handy-dandy Arch Linux bugwrangler utility tool pkg-list-linked-libraries (it does what it says on the tin):

$ pkg-list-linked-libraries r libgfortran.so
==> checking linked libraries for r-3.5.1-2-x86_64.pkg.tar.xz ...
==> ERROR: No file in r-3.5.1-2-x86_64.pkg.tar.xz is linked to libgfortran.so

So, if it is not coming from R itself, where is it coming from? Using the tool lddtree (from pax-utils) to show not just the libraries needed by the executable (like ldd does), but to also show you, in tree format, why they are needed:

$ lddtree /usr/lib/R/bin/exec/R
/usr/lib/R/bin/exec/R (interpreter => /lib64/ld-linux-x86-64.so.2)
    libR.so => /usr/lib/R/lib/libR.so
        libblas.so.3 => /usr/lib/libblas.so.3
            libgfortran.so.5 => /usr/lib/libgfortran.so.5
                libquadmath.so.0 => /usr/lib/libquadmath.so.0
                libgcc_s.so.1 => /usr/lib/libgcc_s.so.1
        libm.so.6 => /usr/lib/libm.so.6
        libreadline.so.7 => /usr/lib/libreadline.so.7
            libncursesw.so.6 => /usr/lib/libncursesw.so.6
        libpcre.so.1 => /usr/lib/libpcre.so.1
        liblzma.so.5 => /usr/lib/liblzma.so.5
        libbz2.so.1.0 => /usr/lib/libbz2.so.1.0
        libz.so.1 => /usr/lib/libz.so.1
        libtirpc.so.3 => /usr/lib/libtirpc.so.3
            libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2
                libkrb5support.so.0 => /usr/lib/libkrb5support.so.0
                libkeyutils.so.1 => /usr/lib/libkeyutils.so.1
                libresolv.so.2 => /usr/lib/libresolv.so.2
            libkrb5.so.3 => /usr/lib/libkrb5.so.3
            libk5crypto.so.3 => /usr/lib/libk5crypto.so.3
            libcom_err.so.2 => /usr/lib/libcom_err.so.2
        librt.so.1 => /usr/lib/librt.so.1
        libdl.so.2 => /usr/lib/libdl.so.2
        libicuuc.so.62 => /usr/lib/libicuuc.so.62
            libicudata.so.62 => /usr/lib/libicudata.so.62
            libstdc++.so.6 => /usr/lib/libstdc++.so.6
        libicui18n.so.62 => /usr/lib/libicui18n.so.62
        libgomp.so.1 => /usr/lib/libgomp.so.1
    libpthread.so.0 => /usr/lib/libpthread.so.0
    libc.so.6 => /usr/lib/libc.so.6

The relevant bit here is the beginning:

/usr/lib/R/bin/exec/R (interpreter => /lib64/ld-linux-x86-64.so.2)
    libR.so => /usr/lib/R/lib/libR.so
        libblas.so.3 => /usr/lib/libblas.so.3
            libgfortran.so.5 => /usr/lib/libgfortran.so.5

And if I delete the libgfortran library because this is a testing chroot and I don't care what happens to it, I see:

/usr/lib/R/bin/exec/R (interpreter => /lib64/ld-linux-x86-64.so.2)
    libR.so => /usr/lib/R/lib/libR.so
        libblas.so.3 => /usr/lib/libblas.so.3
            libgfortran.so.5 => None

This clearly shows that it is libblas.so that has an error finding libgfortran.so, and from there you can check to see what pacman package owns the broken libblas.so -- and if it is truly an official repository package, then you can report a bug to get it fixed, if not, then now you know which AUR package to recompile yourself.

eschwartz
  • 313
  • 1
  • 12
0

I can't say for sure about Arch-Linux, but multiple versions of the gfortran libraries are available on the standard set of repos included with apt on Ubuntu.

When changing to 18.04 (LTS) I had to install the previous version alongside the default version 4 of the libraries.

For me the following command solved this issue: sudo apt-get install libgfortran3

Rebuilding all packages in R may not solve the issue if your package hasn't been maintained in a while, as was my case.

Will C
  • 317
  • 3
  • 8
  • Arch Linux does *not* provide old versions of software as a general rule of thumb. But if we did, then it would be a bug if packages did not correctly specify when they needed that old version. If you're using the Ubuntu distro package for R and that depends on the `libgfortran3` library but only specifies that the `libgfortran` package needs to be installed, then this sounds like a bug in the R package for Ubuntu. – eschwartz Aug 13 '18 at 17:54