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 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
  • 207,228
Sean Elvidge
  • 183
  • 8