Install G77 on Ubuntu >= 9.04

It is possible that you still need to install g77 to compile a Fortran program on your latest version of Ubuntu, but it isn’t the repositories!! Don’t worry, it is easy.


For this install we first need to add the Ubuntu 8.04 repo’s, do this by editing the sources.list file with your favourite text editor. I’ve used gedit here:

sudo gedit /etc/apt/sources.list

Then to the bottom of that file add:

deb hardy universe
deb-src hardy universe
deb hardy-updates universe
deb-src hardy-updates universe

Then we need to run an update and install g77, do this with:

sudo apt-get update
sudo apt-get install g77

Now hopefully g77 will work, to test it try compiling a `Hello World!’ program. With a file name of something like `hello.f’ include the following lines:

       program hello
          print *, "Hello World!"
       end program hello

and then in a terminal window, navigate to the folder containing hello.f and run:

g77 -o hello hello.f

Then (if nothing has gone wrong) be able to run the program `hello’ with:


If you get error messages here then there could be an error with a link, I had such a problem with lgcc_s, to fix this just copy the file to the correct location!

sudo cp /usr/lib/gcc/x86_64-linux-gnu/4.6.3/ /lib/

And everything should work fine. You then will want to disable the old repo’s by adding `##’ in front of each one, i.e. reopen sources.list:

sudo gedit /etc/apt/sources.list

and change the last lines to:

## deb hardy universe
## deb-src hardy universe
## deb hardy-updates universe
## deb-src hardy-updates universe

Now compile away!

5 thoughts on “Install G77 on Ubuntu >= 9.04

  1. Hi,

    I tried to follow your instructions; but, it could not find g77 after “sudo apt-get update” ran fine.

    $ sudo apt-get install g77
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Package g77 is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    Some help would be appreciated.

    1. Thanks for your comment Dushyant. I’m not sure why it failed for you, I’ll look into it. In the mean time I’m glad you managed to get a working solution from stack overflow.

      Thanks 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.