The default GCC version in Ubuntu 12.04 is 4.6. But this version will be on the road when compiling Android 4.0 source code, the following is the method of installing and setting up GCC4.4.
The first method:
Install GCC 4.4
First, install GCC 4.4 (and friends):
apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib
Set 4.4 To is the default
Then set 4.4 to is higher priority than 4.6:
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 100update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 50update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 100update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 50update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.4 100update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.6 50
Verify that it has worked:
gcc -vUsing built-in specs.Target: x86_64-linux-gnuConfigured with: ../src/configure -v --with-pkgversion=‘Ubuntu/Linaro 4.4.6-11ubuntu2‘ --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnuThread model: posixgcc version 4.4.6 (Ubuntu/Linaro 4.4.6-11ubuntu2)
done!
The second method:
GCC-4.4.3 Installation Instructions
Note: The following actions are Root Permissions
because gcc-4.4.3.tar.bz2 and the linux-2.6.32.tar.bz2 These two packages are very large, so you need to download them yourself.
1. Download the required installation package:
1) gcc-4.4.3.tar.bz2
2)gcc -dependent two packages:gmp-4.2.4.tar.bz2 and mpfr-2.3.2.tar.bz2
3) kernel linux-2.6.32.tar.bz2,
2 Decompression and installation
1) New directory
# Cd/home
#mkdir MYGCC
2) Use the tool to copy the downloaded gcc-4.4.3.tar.bz2,gmp-4.2.4.tar.bz2 and mpfr-2.3.2.tar.bz2 compressed packets to Under the MYGCC directory
3) Enter the MYGCC directory for decompression
#cd MYGCC
#tar –xvf tar xvf gcc-4.4.3.tar.bz2
#tar XVF mpfr-2.3.2.tar.bz2
After decompression, the mpfr-2.3.2 directory appears in the current directory, and the directory is renamed to MPFR,
#mv mpfr-2.3.2 MPFR
#tar XVF gmp-4.2.4.tar.bz2
After decompression, the gmp-4.2.4 directory appears in the current directory, and the directory is renamed to GMP,
#mv gmp-4.2.4 GMP
4) Move the renamed two directories to the gcc-4.4.3 directory:
#mv MPFR GMP gcc-4.4.3
5) Set up the target directory to store the installation information
#cd/usr/local
#mkdir gcc-4.4.3
6) configuration
Note: This step must be performed under the target directory, such as my target directory in the/usr/local/gcc-4.4.3 directory.
# /home/mygcc/gcc-4.4.3/configure--prefix=/usr/local/gcc-3.4.0--enable-threads=posix--disable-checking --enable--long-long--enable-languages=c,c++,java
7) Compile (make and next make install operation is still in the target directory, that is, I am here in the/usr/local/gcc-4.4.3 directory)
#make
Note: This step needs to be compiled for a long time, about 50 minutes, you need to wait patiently, if you follow my steps generally do not appear to be the problem. Execute the Make install command after make has finished week.
6) Installation
#make Install
After this step, GCC and the dependent packages are all loaded. At this time my gcc-4.4.3 installed in the/USR/LOCAL/GCC-4.4.3/BIN/GCC, you can not set the environment variables, but each use to indicate the path of GCC4, for example, I want to compile hello.c file, then the command is:/usr/ LOCAL/GCC-4.4.3/BIN/GCC Hello.c–o Hello
Put the GCC execution file in the/usr/bin directory, gcc-4.4 and gcc-4.6 refer to the command when the version is OK, and then in the Bin directory, a shortcut named GCC link to one of the common, so use the command when the version is not used.
GCC-4.6 compiling android4.0 Error installing GCC4.4