How to downgrade gcc, g++ and gfortran compilers?

Asked

Viewed 184 times

1

I’m trying to install the package mice in Rstudio, but the installation fails and shows the error/usr/bin/ld: -lgfortran not found. I noticed that there is no directory called /usr/bin/ld on my PC, but I have gfortran installed. I have never used gfortran fortran in my life, but I suppose gfortran compiles Fortran code in the same way as gcc and g++ compile codeC and C ++, respectively. How did I hear that the R is built in C and Fortran, I decided to check if there is any incompatibility in the version of these compilers. So, rode:

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

The exit 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 installed from each build, I still get the same output. In other words, none of the downgrades went into effect.

So I tried to follow the instructions of the answer to this question. So, I circled:

sudo update-alternative --config gcc

This opens a dialog screen that asks me to select which version of gcc I would like to use by default. I chose 4.9 and then checked again usinggcc --version and it works well. Great.

However, when I ran the same command for g++ and gfortran, I did not have the same success. I noticed, then, that g++ is no longer installed on my PC, because the command gcc --version returns bash: / usr / bin / g ++: no such file or directory. I don’t know what happened, but I think my g++ configuration is related to this. This is my guess, because g++ runs normally when I set up gcc again, using the version 7.4 as a standard.

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

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

returning:

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 is, OS says I already have Fortran 4.9 installed, but when I ask to change the default version it tells me that there are no alternatives, as if in fact I only had the 5.4..

That’s what I’ve tried so far. I have two questions: 1) Am I on track to solve this problem? (otherwise, what should I do? ) 2) If this can solve my problem, how can I downgrade g++ and gfortran?

1 answer

1


Just rotate:

sudo apt-get install r-base-dev

The r-base-dev automatically installs the same version of gcc, g++ and gfortran, in addition to setting each of them as default. To check this, double-check the version of each of the compilers. In my case:

GCC

gcc --version

Output:

gcc (Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010

G++

g++ --version

Output:

g++ (Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010
Copyright (C) 2015 Free Software Foundation, Inc

GFORTRAN

gfortran --version

Output:

GNU Fortran (Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010
Copyright (C) 2015 Free Software Foundation, Inc.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.