I needed to install GCC v4.7 to be able to play with OpenMP v3.1 and
with MIT/Intel Cilk Plus. Although there is a nice GCC installation
page here, I was lacking a step by step tutorial on how to install
it. Here's my crack at it, for my future reference. Maybe it can be of
help to someone else.
mkdir gcc4.7sourcesmv /home/leo/Downloads/gcc-4.7.0.tar.gz gcc4.7sources/cd gcc4.7sources/tar vxzf gcc-4.7.0.tar.gzcd gcc-4.7.0/objdir should not be the same as srcdir, so
mkdir ../objdircd ../objdir/ ../gcc-4.7.0/configure --prefix=/opt/gcc
--program-suffix=-4.7At this point, configure told me that there was a problem with some
dependencies: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and
MPC 0.8.0+. So after a few sudo apt-cache searches:
sudo apt-get install libgmp-devsudo apt-get install libmpfr-devsudo apt-get install libmpc-devAfter that ../gcc-4.7.0/configure --prefix=/opt/
--program-suffix=-4.7 worked just fine. Notice that at this
step, your milage may vary, since you may have to install several
other packages (see here for the prerequisites to build.)
To build in parallel (and take far less time), use the -j
flag and pass it the number of physical cores in your system.
make -j <numcores>I waited for about an hour for it to complete compiling. Then I tried to test,
make -k checkBut there were errors, so I found I was again missing some of the
dependencies. This was solved by installing DejaGnu.
sudo apt-get install dejagnuThen the make -k check script worked fine. Finally, we
need to install this in its final resting place:
sudo make installTo test the final installation, we may do
/opt/gcc/bin/gcc-4.7 --versionsince we have installed it in /opt/. We should get
something like the following: gcc-4.7 (GCC) 4.7.0 .
We may now change the symlinks and compile scripts to compile with
this new version of GCC. Remember to check whether the
linker is linking to the correct libraries.