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 |
## 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 apt-get update |
sudo apt-get install g77 blcr-dkms: blcr-util: dkms: fakeroot: libcr0: libibverbs-dev: openmpi-common: |
sudo vi /etc/apt/sources.list |
sudo apt-get update |
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 |
—————————–
this part is my modification because i’m using Ubuntu 12.04 32bit-i386, after installing g77, i have to change command above because there are some error message,
/usr/bin/ld: error: cannot open crt1.o: No such file or directory /usr/bin/ld: error: cannot open crti.o: No such file or directory /usr/bin/ld: error: cannot open crtn.o: No such file or directory /usr/bin/ld: error: cannot open /usr/lib/gcc/i486-linux-gnu/3.4.6/libgcc_s.so: No such file or directory /usr/bin/ld: error: cannot open /usr/lib/gcc/i486-linux-gnu/3.4.6/libgcc_s.so: No such file or directory collect2: ld returned 1 exit status |
find /usr -name "crt1.o" |
and like above solution:
sudo ln -s /usr/lib/i386-linux-gnu/crt*.o /usr/lib/gcc/i486-linux-gnu/ |
export LIBRARY_PATH=/usr/lib/gcc/i486-linux-gnu:/usr/lib/gcc/i686-linux-gnu/4.6 |
——————————–
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