1

I'm looking for some instructions on how to get the gnu g77 Fortran compiler for the latest LTS version of Ubuntu. I have searched online and all I can find is basically various sites all suggesting to use a download link that no longer exists (example here https://stackoverflow.com/questions/28068148/how-to-install-the-gnu-fortran-77-compiler-or-g77-on-ubuntu-14-04).

I have a program that needs g77 to work. Does anyone know where I can get this installed?

USI9080
  • 11
  • 1
  • 2
  • In my (admittedly limited) experience, trying to install and run g77 involves more pain than biting the bullet and modifying your source and/or build environment to use gfortran. How sure are you that it needs g77 "to work"? – steeldriver Oct 15 '16 at 21:37
  • The software I'm trying to run requires you to pick a Fortran compiler. I have tried f77, f95 and neither work - well, I should say that they appear to work but then the actual program cannot do what it is supposed to do. I didn't write the program and my Fortran experience is non-existent, but I when I looked at the software's website it said that they had tested with g95 and g77 on my linux OS, so I assumed that not using one of these was my issue in the first place. G95 has been giving me as much luck as g77 in my efforts to install it, unfortunately. – USI9080 Oct 15 '16 at 21:49
  • Well all I can suggest is that you try with gfortran, and post specific errors if you have them. – steeldriver Oct 15 '16 at 22:14

1 Answers1

1

I've written a blog post about installing g77 on Ubuntu >=14.04. But the main details are:

Add the Ubuntu 8.04 repo's. Do this by editing the sources.list:

sudo -H gedit /etc/apt/sources.list

Then to the bottom of that file add:

deb http://old-releases.ubuntu.com/ubuntu/ hardy universe
deb-src http://old-releases.ubuntu.com/ubuntu/ hardy universe
deb http://old-releases.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://old-releases.ubuntu.com/ubuntu/ hardy-updates universe

Then run an update and install g77:

sudo apt-get update
sudo apt-get install g77

You might get lucky and g77 might work for you straight away. Likely you'll get an error message, something like:

/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status

This means ld can't find a library (libgcc_s). Find the library yourself, check where ld is looking, and put a link there:

sudo find /usr/ -name libgcc_s.so
ld -lgcc_s --verbose
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so /usr/lib/x86_64-linux-gnu/

(you may have to modify the target and link in the link command depending on the return from the find and ld commands)

EDIT:

David Foerster suggests in the comments that mixing Ubuntu versions is a bad idea. So I should mention that after installing g77 I would then usually edit the /etc/apt/sources.list file again and comment out the 8.04 repos: i.e.

sudo -H gedit /etc/apt/sources.list

and then:

## deb http://old-releases.ubuntu.com/ubuntu/ hardy universe
## deb-src http://old-releases.ubuntu.com/ubuntu/ hardy universe
## deb http://old-releases.ubuntu.com/ubuntu/ hardy-updates universe
## deb-src http://old-releases.ubuntu.com/ubuntu/ hardy-updates universe

I've been installing, and running, g77 like this for the last 5 years or so without any difficulties.

muru
  • 197,895
  • 55
  • 485
  • 740
  • Mixing Ubuntu releases is asking for pain – especially if they're that old. -1 – David Foerster Feb 01 '17 at 13:06
  • I'm sure it is asking for pain (although I've not had any experiences that suggest it is), which is why I would usually comment out the old Ubuntu releases after g77 was installed. With that caveat I can't see any issues with this approach and has worked for me for 5 years or so with no issues. – Sean Elvidge Feb 01 '17 at 14:04
  • 1
    If you do mix repos, what you should use is http://askubuntu.com/a/211964/158442 – muru Feb 01 '17 at 14:13
  • @muru: Excellent hint and thanks for the edit to the answer. I removed my down-vote. – David Foerster Feb 01 '17 at 15:12