. I am using a CentOS6.664-bit system. because the installation of the gcc compiler is not checked during system installation, you need to install the gcc compiler on your own. Install gcc using yum for Linux releases with yum, install gc
For more information about installing the gcc compiler in Linux (CentOS 6.5 64-bit system), I use the 64-bit CentOS 6.6 system, gcc-4.9.2.tar.bz2.
I am using a CentOS 6.6 64-bit system. because the installation of the gcc compiler is not checked during system installation, you need to install the gcc compiler on your own.
Install gcc using yum
For Linux distributions with yum, installing the gcc compiler becomes so easy. We only need to execute the following commands separately:
# Install gcc, c ++ compiler, and kernel file yum-y install gcc-c ++ kernel-devel
Install gcc on your own
However, gcc installed using yum is not the latest version. Currently, the latest version of gcc is 4.9.2 (gcc 4.8 starts to fully support the new features of C 11 and C ++ 11 ). If you want to install the latest version of gcc, you need to install gcc on your own.
When I first installed gcc, I searched for a large number of gcc installation and configuration tutorials on the internet. many tutorials have a lot of content and I am confused, various errors still occur during compilation and installation. After reading the official documents, I found that installing the new version of gcc is not complicated. it is not as complicated as those mentioned in those tutorials (some tutorials still need to modify several configuration files ).
Download the gcc installation file
To install gcc, you must first obtain the gcc installation file. Download gcc-4.9.2.tar.bz2 (86 MB) through the official http://gcc.gnu.org ). Of course, you can download gcc-4.9.2.tar.gz (110 MB), but the size of the compressed file is quite large.
Preparations before compilation
To install gcc 4.8 or a later version, you must first install the C standard library and header files, as well as the c ++ compiler of the earlier version. If you do not have these in your computer, run the following command (you can also use apt-get or other methods for installation, if you have already installed it, you do not need to install it again ):
# Install the static library yum install-y glibc-static libstdc ++ static # install the gcc and C ++ compiler yum install gcc-C + of the old version +
Here, we extract gcc-4.9.2.tar.bz2 to the/usr/local/src Directory (you can also specify other directories). The Complete tar command is:
# Root account, unzip the gcc installation file tar jxf gcc-4.9.2.tar.bz2-C/usr/local/src
After decompression, the gcc source program root directory is/usr/local/src/gcc-4.9.2. Then, execute the following commands in sequence:
# Go to the gcc source program root directory cd/usr/local/src/gcc-4.9.2 # download some essential dependencies./contrib/download_prerequisites
To install gcc, you need to download dependent files such as gmp, mpfr, and mpc. when download_prerequisites is executed, the software will be automatically downloaded and decompressed to the current directory (the file is not large, only a few MB in total, please be patient ).
Compile and install gcc
Then, you can compile and install gcc. Before that, under the root account, we first create a directory/usr/local/build/gcc-4.9.2 (you can also specify other directories) for storing compiled program files. Then execute the following commands in sequence:
Mkdir/usr/local/build/
Mkdir/usr/local/build/gcc-4.9.2
# Jump to the compiled program file storage directory cd/usr/local/build/gcc-4.9.2 # Call the gcc source program configure (subsequent parameter options can be modified as needed ), used to configure gcc/usr/local/src/gcc-4.9.2/configure -- enable-checking = release -- enable-languages ages = c, c ++ -- disable-multilib # to take full advantage of CPU Quad-core, start four threads
make -j4
# It takes a long time to compile the gcc source program. make # install gccmake install
RunMake
The command process may take a lot of time. it may take more than 20 minutes for the author to complete the compilation. After executing the above command, our gcc has been installed successfully.
Gcc-v
You can view the gcc version on the terminal, which has been updated to V4.9.2.
Different from other tutorials, this tutorial does not decompress and compile software such as gmp, mpfr, and mpc, but downloads and decompress download_prerequisites directly, finally, it is recommended to compile and install with gcc (download_prerequisites will decide whether to enable Graphite loop optimization based on the actual situation ).
If you cannot directly connect to the Internet in Linux, you can only open the download_prerequisites file, obtain the download link for these files, and then download the software from other Internet devices. Finally, extract the software directly to the gcc source program directory (/Usr/local/src/gcc-4.9.2
.