2

I recently installed gfortran with apt-get install gfortran, but it turned out to be the latest version 4.9, which is not compatible with software that demanded gfortran in the first place. So I removed it and tried apt-get install gfortran-4.8. The problem is that now it can be run with gfortran-4.8 (obviously) instead of gfortran which is expected by the other software.

Can I make it run with gfortran command?

edit:

I read about aliases and tried setting up ~/.bash_aliases containing

alias gfortran='gfortran-4.8'

but with no effect.

1
  • What kind of build system does that software use? All the sensible ones let you configure things like compiler names/paths through command line options or environment variables. Dec 20, 2014 at 0:05

2 Answers 2

0

I assume you're using something later than Trusty. This isn't a problem in Trusty as gfortran is still at 4.8.

Assuming a downgrade isn't a real solution, I'll just show you how Trusty has things laid out. You might want to check it's similar in whatever you're running to make sure my conclusions are sound:

$ dpkg -S $(which gfortran) $(which gfortran-4.8)
gfortran: /usr/bin/gfortran
gfortran-4.8: /usr/bin/gfortran-4.8

$ file /usr/bin/gfortran
/usr/bin/gfortran: symbolic link to `gfortran-4.8'

So basically here, the gfortran command is just redirecting to /usr/bin/gfortran-4.8. I expect in your version it's redirecting to /usr/bin/gfortran-4.9.

We can override packaged path binaries without touching them. I suggest (and this may undermine things that use gfortran so be careful) we create a new symlink in /usr/local/bin (note the local). When you call gfortran, the system will find the /usr/local/bin/gfortran version first. Note that anything calling /usr/bin/gfortran explicitly will still get the 4.9 version.

Anyway, creating the symlink is easy:

sudo ln -s /usr/bin/gfortran-4.8 /usr/local/bin/gfortran

This has the pleasant side-effect that you can leave your packages in place, fulfilling whatever dependencies you might need to fulfil. And upgrades to the gfortran package won't nuke our changes.

0

What you can do is create a symbolic link (or a "shortcut") for gfortran-4.8 and name the shortcut gfortran.

First, find out where gfortran-4.8 is actually located. You do that by running the command which gfortran-4.8. Let's say you get an output like this:

/usr/bin/gfortran-4.8

What you would do is execute the following command to create the shortcut:

sudo ln -s /usr/bin/gfortran-4.8 /usr/bin/gfortran

Now you (and other programs that were looking for it) should be able to run the program using gfortran.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .