Now many programmers are using GCC, how to better apply gcc. Currently, GCC can be used to compile programs in C + +, FORTRAN, JAVA, OBJC, Ada and other languages, optionally installing the supported languages as required. This article describes the Linux installation GCC process as an example of Redhat Linux installation GCC4.9.2 (which is required during the project development process and is not in the latest GCC version).
Before installation, the system must have a compiler such as CC or GCC, and is available, or use the environment variable CC to specify the compiler on the system. If there is no compiler on the system, you cannot install GCC 4.9.2 in the form of source code. If this is the case, you can use the Internet to find a compatible with your system, such as RPM binary form of the GCC package to install. This article describes the installation process for the GCC packages provided in source code, and the package itself and its installation process apply to other Linux and UNIX systems as well.
The original GCC compiler on the system may be the same as the GCC and other command files, library files, header files, etc. are stored in the system in different directories. Unlike this, GCC now recommends that you install a version of GCC in a separate directory. The advantage of this is that it is easy to delete the entire directory when it is not needed in the future (because GCC does not have the uninstall feature); The disadvantage is that you do some setup work to make the compiler work properly after the installation is complete. In this article, you install GCC 4.9.2, and after the installation is complete, you can still use the earlier version of the GCC compiler, the GCC compiler that can exist on a system and use multiple versions simultaneously.
Following the steps and setup options provided in this article, you can install a new, working version of the GCC compiler on your system, even if you have not previously installed GCC.
1 Downloads
Download resources can be found on the GCC website (http://gcc.gnu.org) or via online search. Currently the latest version of GCC is 4.9.2. The files available for download generally have two forms: gcc-4.9.2.tar.gz and gcc-4.9.2.tar.bz2, except that the compression format is not the same, the content is identical, and one can be downloaded.
Rhlinux installation of the gcc-4.9.2 method is relatively simple, but there are some aspects of the installation process should be noted, otherwise, may cause the installation is unsuccessful, or installation error. The specific installation process is as follows:
First, download and unzip the GCC RPM package to the source directory (e.g./opt/gcc-4.0.1)
1. Unzip the RPM package:
[Email protected]]# tar xjvf gcc-4.0.1.tar.bz2 (Generate source directory/opt/gcc-4.0.1 after decompression)
2. Create the installation target directory:
[Email protected] opt]# MKDIR/USR/LOCAL/GCC-4.0.1/
3. Enter the installation target directory:
[[email protected] opt]# CD/USR/LOCAL/GCC-4.0.1/(This step is important, when you configure the installation file, you need to execute the Configure command in the target directory)
[Email protected] opt]# pwd
/usr/local/gcc-4.0.1
4. Configure the installation file:
[[email protected] gcc-4.0.1]#/opt/gcc-4.0.1/configure--PREFIX=/USR/LOCAL/GCC-4.0.1/(This step is very important, you need to execute the source directory under the target directory of the installation, Configure command in OPT/GCC-4.0.1/, configuring GCC to be installed to target directory/USR/LOCAL/GCC-4.0.1/)
Creating cache./config.cache
Checking host system Type ... I686-pc-linux-gnu
5. Compile the installation file:
[Email protected] gcc-4.0.1]# pwd
/usr/local/gcc-4.0.1
[[email protected] gcc-4.0.1]# make (compile in target directory)
6. Installing GCC:
[Email protected] gcc-4.0.1]# pwd
/usr/local/gcc-4.0.1
[[email protected] gcc-4.0.1]# make install (perform installation in target directory)
If there are no errors in the steps and commands during the installation process, you will certainly be able to install successfully.
From SVN checkout Svn://gcc.gnu.org/svn/gcc/trunk took the latest GCC code, intends to compile learning things to learn C + + 11 of things, the results in configure when the following problems occur:
Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+
1. Download mpc-0.9.tar.gz from Http://www.multiprecision.org/index.php?prog=mpc&page=download
2, ftp://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.bz2 download gmp-5.0.1.tar.bz2
3, http://ftp.gnu.org/gnu/mpfr/download mpfr-3.1.0.tar.xz.
Start installing GMP first. After extracting the GMP compression package, get the source code directory gmp-5.0.1. Create a temporary compilation directory under the directory's sibling directory, named temp here. Then start configuring the installation options, go to the Temp directory and enter the following command to configure:
.. /gmp-5.0.1/configure--prefix=/usr/local/gmp-5.0.1
Make
sudo make install
The installation method of MPFR and MPC is similar to that of GMP. However, you should pay attention to the configuration of the GMP and MPFR dependency options to add, the specific configuration command is as follows:
.. /mpfr-3.1.0/configure--prefix=/usr/local/mpfr-3.1.0--with-gmp=/usr/local/gmp-5.0.1
.. /mpc-0.9/configure--prefix=/usr/local/mpc-0.9--with-gmp=/usr/local/gmp-5.0.1--with-mpfr=/usr/local/mpfr-3.1.0
Once you have installed these three libraries, you are ready to start installing GCC formally.
Of course, when linking, you need to just compile the 3 lib.
Export Ld_library_path= $LD _library_path:/usr/local/mpc-0.9/lib:/usr/local/gmp-5.0.1/lib:/usr/local/mpfr-3.1.0/ Lib
Then is the typical Configure,make,install three-step song.
.. /trunk/configure--prefix=/usr/local/gcc-4.7--enable-threads=posix--disable-checking--disable-multilib-- Enable-languages=c,c++
--with-gmp=/usr/local/gmp-5.0.1--with-mpfr=/usr/local/mpfr-3.1.0--with-mpc=/usr/local/mpc-0.9
Make
Make check (optional)
sudo make install
After a long wait:
/usr/local/gcc-4.7/bin/g++-V
Use built-in specs.
collect_gcc=/usr/local/gcc-4.7/bin/g++
Collect_lto_wrapper=/usr/local/gcc-4.7/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: X86_64-unknown-linux-gnu
Configured as:.. /trunk/configure--prefix=/usr/local/gcc-4.7--enable-threads=posix--disable-checking--disable-multilib-- enable-languages=c,c++--with-gmp=/usr/local/gmp-5.0.1--with-mpfr=/usr/local/mpfr-3.1.0--with-mpc=/usr/local/ mpc-0.9
Threading Model: POSIX
GCC version 4.7.0 20120113 (experimental) (GCC)
Started C + + 11 learning.
Linux upgrade GCC 4.8.1 clear and concise tutorial (Ubuntu 12.04 64-bit version for example) http://www.linuxidc.com/Linux/2014-04/99583.htm
Compiled in CentOS 6.4 install gcc 4.8.1 + gdb 7.6.1 + eclipse in CentOS 6.4 to install GCC 4.8.1 + gdb 7.6.1 + eclipse
Ubuntu under VIM+GCC+GDB installation and use http://www.linuxidc.com/Linux/2013-01/78159.htm
Ubuntu next two gcc version switch http://www.linuxidc.com/Linux/2012-10/72284.htm
CentOS6.5 Upgrade manual Installation GCC4.8.2 http://www.linuxidc.com/Linux/2015-01/112595.htm
detailed description of GCC : please click here
GCC : please click here.
Transferred from:http://www.linuxidc.com/Linux/2015-03/115438.htm
Red Hat Enterprise Linux Server 6.5 installation gcc 4.9.2