How to install other GCC versions in Linux

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.