ubuntu 16.04 LTS demoted installation gcc 4.8
- 2020-05-30 21:58:15
Since gcc modified ABI in version 5.x, the binary files compiled by the new version gcc will report errors in the old environment, so you need to install gcc4.8.5. 4.8.5 this version supports c++11.
First try to download the source code compilation and installation of gcc-4.8.5, make times error "libstdc++.so.6: : version 'CXXABI_1.3.8' not found". Checked under 1, cannot use the new gcc to compile the original gcc source, (� � - '� � ┻ ━ ┻.
In fact, it is easy to install the old version of gcc on ubuntu and download it directly with the apt-get command.
sudo apt-get install gcc-4.8
Enter your password, agree to install, and then automatically download and install version 4.8.5.
Step 2: set the default gcc version
(optional) view the current version and, if not unexpected, return the version 5.4.0 that comes with ubuntu16.04. The new version is still used when compiling with the gcc command.
(optional) check the existing version of gcc and confirm whether 4.8.5 was installed successfully just now.
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
Add a version to the gcc candidate, the last number is the priority, and I set it to 100 myself, no problem.
sudo update-alternatives --config gcc
If you have used this method to configure more than one version of gcc, you will see the following options:
choose The path priority state ------------------------------------------------------------ * 0 /usr/bin/gcc-4.4 50 Automatic 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
Most of the time this is not configured, so no options are given, and the command line returns "only one version of gcc is available." When running gcc --version to view the version, 4.8.5 was found to be the default version of gcc.
Then install g++ in the same way. If only gcc is installed, the c++ code will still be used in the previous version of gcc when the project configured with cmake meets c++ code.
And we're done.