Greetings...

You might also be interested in my research website as well...

Wednesday, May 23, 2012

Installing G77 on Ubuntu 10.04 & 11.10

Alas some of the wave propagation codes I use on my v10.04 and v11.10 Ubuntu Linux systems require the outdated g77 compiler.

However, g77 is no longer being maintained and was last made to support GCC 3.4.  More recent Ubuntu versions use GCC 4.X and so dropped g77 from their default package manager lists.  Took a little bit to figure out how to get the relevant stuff installed and working on these computers, as I still needed the GCC 4.X for other content on the machines.  Here's what I did:

The overall summary is, to get g77 and its libraries you have to temporarily modify an apt-get repository list file, install g77 (which automatically also installs its GCC 3.4 dependencies which won't interfere with your gcc 4.x), and then set the repository file back to its original state.  Also, there's an additional little fix to install g77 in Ubuntu 11.10 that wasn't in Ubuntu 10.04 (I haven't tried the versions of Ubuntu in between): a few libs moved location, so you simply use an environment variable to tell g77 where they are.  Steps detailed below:

sudo vi /etc/apt/sources.list, then append the following lines to end of file:

## temporarily adding these to install G77 which is no longer supported:
deb http://hu.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://hu.archive.ubuntu.com/ubuntu/ hardy universe
deb http://hu.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://hu.archive.ubuntu.com/ubuntu/ hardy-updates universe

sudo aptitude update

sudo aptitude install g77 blcr-dkms: blcr-util: dkms: fakeroot: libcr0: libibverbs-dev: openmpi-common:
(Those entries with colons afterward prevent those packages from being removed to match the outdated setup, which we don't wish to do)

sudo vi /etc/apt/sources.list again and comment out those above lines at end of file.

sudo aptitude update

If you're running Ubuntu 11.10 (but this is not needed for 10.04; I don't know about versions in between, the error is about finding libs crt1.o, crti.o and lgcc_s):
Before running make (or g77 in general) you'll need to enter the following line in your shell (note this is bash style here, mod as needed for other shells):

export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/gcc/x86_64-linux-gnu/4.6

(Note that is not the more common variable LD_LIBRARY_PATH...)

If you plan to do a lot of g77 compiles you might wish to add that LIBRARY_PATH line to your ~/.bashrc file, but for just one or two compiles I personally choose not to do so.

Note that executables made with this g77 may rely by default on shared object libraries of g77/gcc 3.4, so if you copy your executable over to other modern Linux systems (say another 10.04 or 11.10 box -- e.g. I use mine in a cluster), you may get a runtime error about shared object files.  The solution is to install g77 on that other system as well by the same instructions above, so that the shared object files exist.  It goes pretty quickly after the first time.

11 comments:

  1. You saved me man, thank you very much !!!

    ReplyDelete
  2. thx a lot, Mr. Ganse.

    btw do you know how to install gcc 3.2.2 in ubuntu lucid?

    ReplyDelete
  3. Hi Gema,
    Well my short answer is "Sorry, I don't really know." (That G77 thing took me forever!) But after looking around a bit, hopefully the following two leads may be helpful to you:

    1.) This ubuntu forum page (http://askubuntu.com/questions/39628/old-version-of-gcc-for-new-ubuntu) says there's another repository called "lucid-backports" which looks promising. However their example was regarding gcc3.3 and I do not know how far back those backports go, but I would say that's definitely a place worth checking.
    2.) An admittedly less appealing option is trying to compile the thing from source. It's been a while since I've done that myself, but note in generally it will take some hours even in the best cases. I.e. definitely expect to be working on another project during compiling stages. This forum page (http://ubuntuforums.org/showthread.php?t=1682774) has some helpful details for downloading and compiling older versions of gcc on ubuntu, including a mirror site with the source.

    In both these cases, I think the more frustrating thing can be if you're trying to keep your more modern version of gcc and its libs present and functional at the same time as this old one. If that's an interest of yours, just be sure keep it in mind as you read the various readme/instructions files when compiling as there are usually special additional instructions for that case.

    Best of luck! Cheers, -Andy

    ReplyDelete
  4. (Hmm, not sure why those URLs I listed aren't turning into links in the published response, sorry! -AG)

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Hi Andy,
    I try this for ubuntu 12.04 but when I do
    sudo apt-get-update
    I have failed from the links

    W: Failed to fetch http://hu.archive.ubuntu.com/ubuntu/dists/hardy/universe/source/Sources 404 Not Found
    W: Failed to fetch http://hu.archive.ubuntu.com/ubuntu/dists/hardy/universe/binary-amd64/Packages 404 Not Found
    W: Failed to fetch http://hu.archive.ubuntu.com/ubuntu/dists/hardy/universe/binary-i386/Packages 404 Not Found
    W: Failed to fetch http://hu.archive.ubuntu.com/ubuntu/dists/hardy-updates/universe/source/Sources 404 Not Found
    W: Failed to fetch http://hu.archive.ubuntu.com/ubuntu/dists/hardy-updates/universe/binary-amd64/Packages 404 Not Found
    W: Failed to fetch http://hu.archive.ubuntu.com/ubuntu/dists/hardy-updates/universe/binary-i386/Packages 404 Not Found

    E: Some index files failed to download. They have been ignored, or old ones used instead.

    sudo apt-get install g77 blcr-dkms: blcr-util: dkms: fakeroot: libcr0: libibverbs-dev: openmpi-common:
    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

    E: Package 'g77' has no installation candidate

    Do you have an idea to install g77 ?
    Thanks
    Elodie

    ReplyDelete
  10. Hi
    I tried the same method you just described above, that is:
    modify the sources.list file
    run the commands in the terminal–
    sudo apt-get update
    sudo apt-get install g77

    But I still couldn’t get the g77 installed, the prompt says:
    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

    E: Package ‘g77′ has no installation candidate

    What did I mess up??? I am using Ubuntu 12.04 LTS. Any suggestion would be highly appreciated.

    ReplyDelete
  11. Hi Andy, Do you think maybe the reason is the g77 in the repository has been removed?

    ReplyDelete