How to install other GCC versions in Linux
Preface
Sometimes, a fixed version of GCC needs to be installed in Linux to meet work requirements. For example, in Fedora22, compiling the cuda part of OpenCV requires GCC 4.9.X and earlier versions, while GCC of Fedora22 is between 5.1 and 5.3. For example, compiling matcaffe in Caffe requires GCC 4.7.X and later versions. Therefore, when installing an earlier version of GCC, you must do it yourself. The following are common operations:
1. Download GCC
Go to the GCC official website http://www.gnu.org/prep/ftp.html to find China and select an image address. For example, http://developer.hust.edu.cn/gnu/gcc /. Select the corresponding version of gcc-4.9.4/, download gcc-4.9.4.tar.gz compressed package to local.
Decompress the package to the current folder:
$ tar -zxvf gcc-4.9.4.tar.gz
2. Download the dependencies required for compilation
$ cd gcc-4.9.4$ ./contrib/download_prerequisites $ cd ..
3. Create a compilation output directory
$ mkdir gcc-build-4.9.4
4. Generate the makefile file
Enter the output directory, execute the command, and generate the makefile file File
$ cd gcc-build-4.9.4$ ../gcc-4.9.4/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
5. Compile
$ make -j24
The next step is to wait for about 40 minutes. PS: it is best not to do anything in the compilation process. The CPU is fully loaded throughout the process. If it is inexplicably terminated, there will be a lot of troubles in the future.
6. Install
After compilation, we can execute the installation:
# make install
7. Check the version
$ gcc -v$ g++ -v
Linux GCC 4.8.1 clear and concise tutorial (Ubuntu 12.04 64-bit edition as an example)
Install GCC 4.1.2 on Ubuntu 14.04 LST
Install and use Vim + GCC + GDB in Ubuntu
Switch two GCC versions in Ubuntu
CentOS6.5 upgrade to manually install GCC4.8.2
GCC details: click here
This article permanently updates the link address: