This post is a translation about one I posted in Portuguese. This is very interesting and I decide to do that.
As usual, before to start the installation we need to install some packages that are required. Open a shell and type:
sudo apt-get install mpc libmpc-dev libmpfr-dev libppl0.10-dev libcloog-ppl-dev zlib1g zlib1g-dev libc6-dev-i386 m4 flex
Also we need to install the package gmp, however it doesn’t have in the Ubuntu’s repository. So, this one we will have to install it manually. Download it from packages.ubuntu.com and follow the procedure below to install it.
– Extract the file: tar xvf gmp_4.3.2+dfsg.orig.tar.gz
– Using a shell, access the folder uncompressed
– Run:
./configure
make
sudo make install
make check
From GNU site, download the file gcc-4.6-20110401.tar.bz2 to a folder called gcc.
Using a shell, go to gcc folder and extract the file:
tar xjvf gcc-4.6-20110401.tar.bz2
Still in gcc folder, create another folder called build:
mkdir build
Now you will have a directory structure like this:
gcc/build
gcc/gcc-4.6-20110401
Finally, it’s time to compile the GCC. Access the build folder and run:
../gcc-4.6-20110401/configure \
--disable-checking \
--enable-languages=c,c++ \
--enable-multiarch \
--enable-shared \
--enable-threads=posix \
--program-suffix=-4.6 \
--with-gmp=/usr/local/lib \
--with-mpc=/usr/lib \
--with-mpfr=/usr/lib \
--without-included-gettext \
--with-system-zlib \
--with-tune=generic
make
sudo make install
Finished the compilation, we need to say to Ubuntu to use the new GCC:
cd /usr/bin
sudo rm g++
sudo ln -s /usr/local/bin/g++-4.6 g++
sudo rm gcc
sudo ln -s /usr/local/bin/gcc-4.6 gcc
In this post, I opted to compile just “C” and “C++”, although you can add others components to be compiled according with GNU site. However, you already must have realized, I downloaded the full GNU distribution and compiled just 2 languages. I could use the option “all” in –enable-languages but I was getting error when it started to compile the Java module. I will investigate that and I will post here in this blog the solution.
That’s it folks. Any doubts or suggestion, feel free to comment. More information about how to compile GCC, you can find in GNU site.
See you next time.