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
sudo make install
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:
Now you will have a directory structure like this:
Finally, it’s time to compile the GCC. Access the build folder and run:
sudo make install
Finished the compilation, we need to say to Ubuntu to use the new GCC:
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.