1

I'm trying to install the package mice in Rstudio but the installation fails and shows the error /usr/bin/ld: cannot find -lgfortran. I note that there is no directory called /usr/bin/ld in my PC, but I have gfortran installed. I have never used fortran in my life but I suppose that gfortran compiles fortran code in the same way that gcc and g++ compiles C and C++ code, respectively. As I heard that R is built on C and Fortran I decide to check if there is some incompatibility in the version of these compilers. Then I ran:

gcc --version
g++ --version
gfortran --version

The output was:

gcc (Ubuntu 7.4.0-1ubuntu1~16.04~ppa1) 7.4.0
g++ (Ubuntu 7.4.0-1ubuntu1~16.04~ppa1) 7.4.0
GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609

As it turns out, I have different versions installed. To solve this I ran:

sudo apt-get install --reinstall gfortran-4.9
sudo apt-get install --reinstall g++-4.9
sudo apt-get install --reinstall gcc-4.9

However, when I check again which version I have installed of each compile I still get the same output. In other words, none of the downgrades took effect.

Then I try to follow the instructions from the answer to this question. Thus I ran:

sudo update-alternatives --config gcc

This open a dialog screen that asks me to select which version of gcc I would like to use as default. I chose 4.9 and then I check again using gcc --version and it works fine. Great.

Nevertheless, when I ran the same command for g++ and gfortran I didn't have the same success. In fact, it turns out that g++ is no longer installed in my PC since the command gcc --version returns bash: /usr/bin/g++: No such file or directory. I didn't know what happened, but I guess that my configuration of g++ is related to that. That's my guess because g++ runs normally when I configure gcc again using the 7.4 version as default.

Regarding gfortran, my problem is a bit different. When I tried to change the default version the shell returns error: no alternatives for gfortran. Then I tried the gfortran installation again using:

sudo apt-get update
sudo apt-get install gfortran-4.9

which returns:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
gfortran-4.9 is already the newest version (4.9.4-2ubuntu1~16.04).
0 upgraded, 0 newly installed, 0 to remove and 408 not upgraded.

That's what I have tried until now. I have two questions: 1) Am I in the right way to solve this problem? (if not, what should I do?) 2) If this can solve my problem, how can I downgrade g++, and gfortran?

Lucas
  • 213

0 Answers0