Linux installation gcc compiler detailed

Source: Internet
Author: User
Tags bz2 gmp

I am using the CentOS 6.5 64-bit system, since the installation of the system is not checked to install the GCC compiler, so you need to install the GCC compiler yourself.

Installing GCC with Yum

For Linux distributions with Yum, installing the GCC compiler becomes so easy. We only need to execute the following commands separately:

#安装gcc, C + + compilers, and kernel files
-y install gcc gcc-c+ + kernel-devel
Self-installing GCC

However, the most recent version of GCC is 4.9.0 (gcc 4.8 starts with the new features of C 11 and C + + 11) that are not currently the latest version of GCC installed with Yum. If we want to install the latest version of GCC, we need to install GCC on our own.

The first time I installed gcc, I searched the network for a large number of GCC installation configuration tutorials, many of the content of the tutorial is very much, the results of their own dizzy, compile and install the time there are always a variety of errors. Finally, the official documents found that the installation of the new version of the GCC is not complicated, it is not as cumbersome as those in the tutorial (some of the tutorials actually have to modify several configuration files).

Download GCC installation files

In the installation of GCC, of course, you must first get the GCC installation files. Here we directly download gcc-4.9.0.tar.bz2 (MB) from the official website. Of course, you can also download gcc-4.9.0.tar.gz (MB), but the compressed file is a lot larger.

Pre-compilation preparation work

To install GCC 4.8 and later, you need to first install the C standard library and header files, as well as the older C + + compilers. If you do not have these on your computer, execute the following commands (you can, of course, install them in other ways, such as Apt-get, which you do not need to install again if installed):

static libraries for #安装C和C + +
-y glibc-static libstdc++-Static
#安装旧版本的gcc, C + + compiler
Yum install gcc gcc-c+ +

Here we extract the gcc-4.9.0.tar.bz2 into the/USR/LOCAL/SRC directory (you can also specify a different directory, of course), and the Complete tar command is:

#解压gcc安装文件
Tar jxf gcc-4.9. 0.tar. -/usr/local/src

The root directory of the GCC source program after decompression is/usr/local/src/gcc-4.9.0. Next, we execute the following command in turn:

#转到gcc源程序根目录
/usr/local/src/gcc-4.9. 0
#下载一些必备的依赖程序
./Contrib/download_prerequisites
install gcc need to download such as GMP, MPFR, MPC and other dependent files, execution download_prerequisites will automatically download the software and extract to the current directory (the file is small, a total of only a few MB, please wait for the download).
Compiling and installing GCC

The GCC can then be compiled and installed. Before we do this, we'll create a directory/usr/local/build/gcc-4.9.0 (you can also specify a different directory yourself) to hold the compiled program files. We then execute the following command in turn:

#跳转到编译后的程序文件存放目录
Cd/Usr/Local/Build/Gcc-4.9.0
#调用gcc源程序的configure (The following parameter options are self-modifying as needed) for configuring GCC
/Usr/Local/src/gcc- 4.9. 0/configure --enable- checking=release -- Enable-languages=c,< Span class= "PLN" >c++ --disable -multilib
#编译gcc源程序
Make
Span class= "com" > #安装gcc
Make install

The make process of executing commands can take a lot of time, and it takes more than 20 minutes for the author to compile. After executing the above command, our GCC has been installed successfully.

Unlike other tutorials, the tutorial does not extract and compile GMP, MPFR, MPC and other software, but is directly responsible for the download and decompression by download_prerequisites, and finally compiles and installs with GCC, which is also the official recommended practice ( Download_prerequisites also determines whether graphite cycle optimization is enabled, depending on the actual situation.

If your Linux is not connected directly, you can only open the file download_prerequisites, get the download link to these files, and then download the software from other Internet devices. Finally, the software can be extracted directly into the GCC source program directory ( /usr/local/src/gcc-4.9.0 ).

Software Compass (http://www.softown.cn), reproduced please keep the source!

Linux installation gcc compiler detailed

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.