These days I encountered a lot of problems in configuring the Linux kernel for cross-compiling the arm board, including the issue of the GCC version too high, so I intend to install the other old version to my Ubuntu16.04. The experiment is as follows:
1 . First, check out the original GCC version of the current Ubuntu16.04 version:
gcc-v #查看gcc的版本g+ v #查看g + + versions
As shown: The GCC version is 5.4.0 (it is really too new for me to compile some very early kernel files)
2, the installation currently requires GCC and g++ version (currently installed is the gcc-4.8.5 version):
Before this, I tried to download the source file to compile the installation method, encountered too many problems, first recorded in this, and then resolved, first Use Apt-get installation method:
sudo apt-get install gcc-4.8 g++-4.8
I've installed it, show it.
After you install, you can use the following instructions to view all the GCC and g++ versions that are installed on the current system:
ls/usr/bin/gcc*/usr/bin/g++*
3, a version to join the GCC candidate, the final number is priority, I am directly set to 100 (Test no problem), the instructions are as follows:
sudo update-alternatives--install/usr/bin/gcc gcc/usr/bin/gcc-4.8
We also changed the priority of GCC and g++ in the original system to 100 so that we could not restore the default priority version after we had selected the current version.
sudo update-alternatives--install/usr/bin/gcc gcc/usr/bin/gcc-5
4, after the completion of the above operation, we can choose the different GCC and g++ versions by the following instructions (note that before using to ensure that there are at least two GCC or g++ version of the operation of the 3rd step):
sudo update-alternatives--config gcc
Here we choose 2, which is the gcc-4.8 version, and then see if the current version has been switched over.
Gcc-v
That means it's really switched over.
We can use the same method to select g++:
OK, we've all switched over, cheers!.
Note a problem:
When switching to other versions of GCC, it is important to maintain consistency between the g++ version and the GCC version, otherwise the project configured with CMake will encounter C + + code or a previous version of GCC.
A tutorial on directly compiling and installing GCC can be found here (although I have not succeeded): http://blog.csdn.net/ws_20100/article/details/51207372
Ubuntu16.04 installation and switching of multiple versions of the GCC compiler