Here I describe how I compiled and installed gcc supporting C, C++ and Fortran languages on an Alpha machine (HP TestDrive System). What you see here is what I tried and worked, but there is no guarantee that these instructions work for you too!
The list below shows the conditions that I was working in and some hints before starting the work:
- I tried to install gcc in my own home directory, because I didn't have root access.
If you have root access, you may not want to use "--prefix=..." to configure the packages.
- If you have already installed another version of gcc, remove it from your path so that
the scripts do not use it and use the one that comes with Tru64 OS. Besides don't try to install gcc in the same directory and pick a new directory for this purpose.
- I was using bash.
Before starting to download and install gcc, you need GMP and MPFR if you want to enable Fortran language.
To download and install GMP follow these steps:
If you don't need Fortran, you can skip the installation of GMP and MPFR.
Now you can download and install MPFR.
- Download GMP from http://www.swox.com/gmp/
- copy the file to /tmp and uncompress it there. Let's assume that the extracted files are in /tmp/gmp-4.2.1
- cd /tmp/gmp-4.2.1
- ./configure --prefix=$HOME/progs/gmp
- make check
Check the messages and make sure that no test failed.
- make install
To do so follow these steps:
You need libiconv in order to build gcc correctly. I tried a few different options like using --disable-nls to avoid installing libiconv, but none of
them worked. Therefore, I decided to install libiconv too. To install libiconv follow these steps:
- Download MPFR from http://www.mpfr.org/mpfr-current/
- copy the file to /tmp and uncompress it there. Let's assume that the extracted files are in /tmp/mpfr-2.2.0
- Check the website for any available patches and apply them if there is any
Note: Use /usr/local/bin/patch to apply any existing patch.
- cd /tmp/mpfr-2-2.0
- LD_LIBRARY_PATH=$HOME/progs/gmp/lib:$LD_LIBRARY_PATH ./configure --prefix=$HOME/progs/mpfr --with-gmp=$HOME/progs/gmp
- gmake check
- gmake install
Now you are ready to build and install gcc:
- Download libiconv from http://www.gnu.org/software/libiconv/
- copy the file to /tmp and uncompress it there. Let's assume that the extracted files are in /tmp/libiconv
- cd /tmp/libiconv
- ./configure --prefix=$HOME/progs/libiconv
- make install
At this point, you must have a working gcc installed in $HOME/gcc. You can set your paths to use the new version of the compiler set.
- Download gcc from http://gcc.gnu.org
- Uncompress the file under a directory in /tmp. Let's assume that the extracted files are in /tmp/gcc-4.1.1/
Note: You should use gtar to untar the file, otherwise you will get some errors similar to this:
tar: ././@LongLink : Unknown filetype
- Create another directory in /tmp. Let's call this directory gcc-build
Note: If you are using HP TestDrive systems, it is important to use /tmp, because you don't have enough disk quota in your home directory to compile gcc.
- cd /tmp/gcc-build
- CC="gcc -Wa,-oldas" /tmp/gcc-4.1.1/configure --prefix=$HOME/gcc --enable-languages=c,c++,fortran --with-gmp=$HOME/progs/gmp --with-mpfr=$HOME/progs/mpfr --with-libiconv-prefix=$HOME/progs/libiconv
If you don't need C++, omit it from --enable-languages. C++ takes a relatively large amount of disk space.
If you don't need Fortran, use this command instead:
CC="gcc -Wa,-oldas" /tmp/gcc-4.1.1/configure --prefix=$HOME/gcc --enable-languages=c,c++ --with-libiconv-prefix=$HOME/progs/libiconv
- LD_LIBRARY_PATH=$HOME/progs/gmp/lib:$LD_LIBRARY_PATH gmake bootstrap-lean
Note: You should use GNU make (gmake) version 3.80 or higher to build gcc.
This step takes a long time, usually a few hours!
If you don't want to install Fortran simply use:
- gmake install
If tar complains that it failed to preserve ownership of files, you'll need to change the ownership of /tmp/gcc-build.
Go to your home directory and run ls -l. In my case the problem was from group name. The group name of all the files in my home directory was nis while the group name of /tmp/gcc-build and all the files under the directory was system.
So, I ran chown -hR MyUsername:nis /tmp/gcc-build then I removed $HOME/gcc and ran gmake install again.
Now it is time to remove the folders and files that you have created in /tmp. In our example: /tmp/gcc-4.1.1, /tmp/gcc-build, /tmp/libiconv, /tmp/mpfr-2.2.0, /tmp/gmp-4.2.1
July 26, 2006