Thursday, May 2, 2024
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 608  / 2 Years ago, sat, february 5, 2022, 4:05:13

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.


More From » command-line

 Answers
2

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.


[#21986] Saturday, February 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
iedncommon

Total Points: 200
Total Questions: 95
Total Answers: 132

Location: Tonga
Member since Mon, Aug 2, 2021
3 Years ago
iedncommon questions
Sat, Jun 4, 22, 18:20, 2 Years ago
Mon, Apr 4, 22, 08:10, 2 Years ago
Tue, Jul 6, 21, 15:11, 3 Years ago
;