The version of GCC used in Ubuntu is different from the release version, and when compiling the Android system different versions are recommended to compile with different gcc, so can you change the system's GCC to suit the needs of the Android build environment? The answer is yes.
Let's see what the GCC and g++ are for our system.
Gcc-v
The information you can get is as follows
GCC version 4.4.6 (Ubuntu/linaro 4.4.6-11ubuntu2)
What if we want to use gcc4.5? First see if there is gcc4.5 installed,
ls/usr/bin/gcc*
Results only/usr/bin/gcc/usr/bin/gcc-4.4 Two, then we need to install
sudo apt-get install gcc-4.5 gcc-4.5-multilib g++-4.5 g++-4.5-multilib
After installation, enter the following command:
sudo update-alternatives--install/usr/bin/gcc gcc/usr/bin/gcc-4.4 50
sudo update-alternatives--INSTALL/USR/BIN/GCC gcc/usr/bin/gcc-4.5 40
Then enter:
sudo update-alternatives--config gcc
You will see the following options
There are 3 candidates that can be used to replace GCC (provides/USR/BIN/GCC).
Select Path Priority state
------------------------------------------------------------
* 0/usr/bin/gcc-4.4 50 Auto mode
1/usr/bin/gcc-4.4 50 Manual Mode
2/usr/bin/gcc-4.5 40 Manual Mode
3/usr/bin/gcc-4.6 30 Manual Mode
To maintain the current value [*], press ENTER, or type the number you selected:
If you want to use which GCC, enter the number.
Also set the g++
sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.4 50
sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.5 40
If you want to delete the optional option, you can type the following command:
sudo update-alternatives--remove gcc/usr/bin/gcc-4.5
Then use GCC-V to see if the version has changed.
Ubuntu next two versions of GCC switch