Version 3 (modified by Eddu, 15 years ago) ( diff )

wrong command for test summary (version) was 3.4.3

Installing a Fortran compiler using GCC-3.4.6

These instructions are specific for installation of a Fortran compiler into the /opt/gcc-3.4.6 directory structure using the GCC-3.4.6 source files. A C compiler will also be installed but it will not interfere with or affect your existing C compiler.

Instead of the opt/gcc-3.4.6 directory structure, you may want (or need) to install the compilers into a private directory, or some other location. Do keep in mind that wherever you install it, you'll need to create symbolic links to the and library links, if these links are not located where they will be picked up by the linker's cache (/lib, /usr/lib, or any location defined in /etc/

Downloading the Sources

Package Tarballs

First you need to download the two source tarballs you'll need:

If you have the DejaGnu package installed (requires Expect and Tcl), you should also download the testsuite tarball:

Alternatively, download the complete tarball which includes all the compilers and the testsuite:

Required Patches

You'll also need to download two patches:

Preparing the Sources

Unpack the source tarballs. Everything will unpack into a gcc-3.4.6 directory. Change into the newly created gcc-3.4.6 directory, apply the two patches and issue a sed command:

patch -Np1 -i ../gcc-3.4.3-no_fixincludes-1.patch &&
patch -Np1 -i ../gcc-3.4.3-linkonce-1.patch
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/

Install the Compilers

Note that these instructions only install the C and Fortran compilers. If you wish to install additional compilers (not including the Ada compiler), add them to the configure command below. Exercise caution installing the C++ compiler as the libraries could conflict with your existing system C++ libraries. Additionally, you can adjust the --prefix= parameter to install the compilers in a location other than /opt/gcc-3.4.6. Issue the following commands as an unprivileged user:

mkdir ../gcc-build &&
cd ../gcc-build &&
../gcc-3.4.6/configure --prefix=/opt/gcc-3.4.6 \
                       --libexecdir=/opt/gcc-3.4.6/lib \
                       --enable-shared \
                       --enable-threads=posix \
                       --enable-__cxa_atexit \
                       --enable-clocale=gnu \
                       --enable-languages=c,f77 &
make bootstrap &&
make -k check &&
../gcc-3.4.6/contrib/test_summary &&
../gcc-3.4.6/contrib/test_summary | grep -A7 Summ

Go get a cup of coffee because this is going to take a while. The last couple of commands will produce summaries of the test results. There should be no errors produced by the Fortran tests and only one error produced from the tests of the C compiler.

You may need to switch to the root user for the remainder of the installation:

make install &&
ln -v -s gcc /opt/gcc-3.4.6/bin/cc &&
ln -v -s g77 /opt/gcc-3.4.6/bin/f77 &&
ln -v -s /opt/gcc-3.4.6/lib/ /usr/lib &&
ln -v -s /opt/gcc-3.4.6/lib/ /usr/lib

Your Fortran compiler is now installed. Using it is as simple as putting the directory where the g77 file and the f77 links are located at the beginning of your PATH. For example, at the beginning of a compilation requiring a Fortran compiler, issue these commands:

export PATH=/opt/gcc-3.4.6/bin:$PATH_HOLD
echo $PATH

If you have which installed, issue: which gcc, and this can confirm you are using the compiler you think you are. When finished, log out and back in again, or restore your path by issuing: export PATH=$PATH_HOLD.


Note: See TracWiki for help on using the wiki.