Installing GCC 4.6 in the Ubuntu 10.10

Posted: April 20, 2011 in Ubuntu
Tags: , ,

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 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:

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:


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 \
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.

  1. ketan says:

    Hey, i followed the steps exactly as given, but when i did gcc –version it still showed version 4.4.5..How do i run this version?

  2. Filip Luch says:

    hi! thx for your instructions. but is it ok for the terminal to work for more than half an hour? ) its still writing everything…and wrinting..and writing…)

  3. Filip Luch says:

    how do i run gcc after installing?

  4. Filip Luch says:

    how do i start gcc after installing everything>?

  5. sanjeev says:

    Thanks for this. For gcc-4.7 on a clean 64bit system without any i386 package installed, the make fails. I have to install libc6-dev-i386 to make the make succeed.

  6. Keith Thompson says:

    gmp is available in the repository. Try “apt-cache search libgmp” to see the available package names.

  7. Hi, I compiles the package successfully for to configure the latest version i tried to follow steps mentioned in

    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

    It doesn’t created files like, /usr/local/bin/g++-4.6, /usr/local/bin/gcc-4.6. Where does they exists?
    I tried with the version gcc-4.6-20111028.tar.bz2.tar.bz2.tar.bz2.on ubuntu 11.04.
    Please help me.

  8. ketan says:

    It works. thanks.
    Though I think libc6-dev-i386 is required for only amd64.

  9. Dan says:

    After compiling gcc, the command “make” takes forever, just as a head’s up for people. It took me an hour and a half to finish on an i5 processor.

  10. farid says:

    hi whats this prob (when install it )
    C compiler cannot create executables

  11. raj says:

    after completion of GCC, can you tell me how to run it ?

  12. Micmec says:

    Can you help me installing gcc 4.6.1 in ubuntu 13.04..?
    I’m having error :

    /usr/bin/ld: cannot find crti.o: No such file or directory
    collect2: ld returned 1 exit status
    make[3]: *** [] Error 1
    make[3]: Leaving directory `/home/michael/Downloads/gcc-4.6.1/build/i686-pc-linux-gnu/libgcc’
    make[2]: *** [all-stage1-target-libgcc] Error 2
    make[2]: Leaving directory `/home/michael/Downloads/gcc-4.6.1/build’
    make[1]: *** [stage1-bubble] Error 2
    make[1]: Leaving directory `/home/michael/Downloads/gcc-4.6.1/build’
    make: *** [all] Error 2

    I’m stuck at there…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s