CentOS offline installation of gcc (version 4.8.2
- 2020-05-17 07:27:58
- OfStack
CentOS installs gcc offline
Toss 1 day, kung fu pays off, finally out, or very excited. Without further ado, get straight to the point.
First, installing gcc4.8.2 under CentOS requires the installation of three packages, GMP, MPFR and MPC.
Installation package download address
From http: / / gcc. gnu. org/download gcc installation package gcc - 4.8.2. tar. gz
From ftp: / / ftp. gnu. org/download/gnu gmp GMP installation package gmp - 5.1.3. tar. bz2
From http: / / ftp. gnu. org/download/gnu mpfr MPFR installation package mpfr - 3.1.2. tar. gz
From http: / / www. cise. ufl. edu/mirrors/GNU/pub gnu/download mpc MPC installation package mpc - 1.0.1. tar. gz
The installation steps are as follows:
Extract the GMP, MPFR and MPC packages into separate files.
Install gmp
[root@liuyanmin ~]# cd gmp-5.1.3
[root@liuyanmin gmp-5.1.3]# ./configure
[root@liuyanmin gmp-5.1.3]# make
[root@liuyanmin gmp-5.1.3]# make check
This step is necessary to check if there is any file mismatch or missing, and at the end of the prompt, please pay attention to the prompt of Erro, if there is no indication that the installation is normal. There is no error in the installation process, please let me know if there is any problem in the compilation process.
[root@liuyanmin gmp-5.1.3]# make install
Install the compiled software and complete the installation process
It is necessary to specify the location of the program's header file (.h) and library file (lib*). This installation will be installed in /usr/local/include and /usr/local/lib.
Install mpfr
[root@liuyanmin ~]# cd mpfr-3.1.2
[root@liuyanmin mpfr-3.1.2]# ./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib
[root@liuyanmin mpfr-3.1.2]# make
[root@liuyanmin mpfr-3.1.2]# make check
Always check for errors in each step. I have no errors at compile time.
[root@liuyanmin gmp-5.1.3]# make install
Install MPC
[root@liuyanmin ~]# cd mpc-1.0.1
[root@liuyanmin mpc-1.0.1]# ./configure
[root@liuyanmin mpc-1.0.1]# make
[root@liuyanmin mpc-1.0.1]# make check
[root@liuyanmin mpc-1.0.1]# make install
After the above installation is successful, you will also configure the lib directory, which is required at compile time for gcc
[root@liuyanmin mpc-1.0.1]# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
This time you can install gcc
Create the gcc installation directory /usr/gcc482
Unzip gcc 4.8.2 and enter the directory after unzip. Open the command terminal and execute
[root@liuyanmin gcc4.8.2]#
./configure --prefix=/usr/gcc482 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++
[root@liuyanmin gcc4.8.2]# make
[root@liuyanmin gcc4.8.2]# make install
Now the installation of gcc4.8.2 has been completed, but the environment variable of gcc4.8.2 has not been set, and the old version of gcc is still used in the system.
Just now we installed gcc4.8.2 under /usr/gcc482. If you don't know, you can find 1 in the following step.
Determine the path to the newly installed GCC, updatedb first, then locate gcc-4.8| tail find 1.
See gcc 4.8.2 below
ls /usr/gcc482/bin | grep gcc
Setup using the new gcc 4.8.2 method, I now have two.
Method 1:
Add gcc 4.8.2 to optional:
update-alternatives --install /usr/bin/gcc gcc /usr/gcc482/bin/i686-pc-Linux-gnu-gcc 40
The last parameter is the name. The second parameter is the new GCC path. The last parameter 40 is the priority
That is the way I found from the Internet, but I tried, but gcc -- v shows or old version update - alternatives - display gcc display correctly again, imagine gcc482 we are installed, but it's the execution path and lib did not set in the system, and gcc v will certainly from the execution path to find, so it shows that the result is the old version gcc again very normal, I also wondered for it now, Which know the reason of failure, hope you shrimp more advice ah!
Method 2:
This method is very simple, you can set the soft link
[root@liuym usr]# mkdir /usr/gcc447backup/
[root@liuym usr]# mv /usr/bin/{gcc,g++} /usr/gcc447backup
[root@liuym usr]# ln -s /usr/gcc482/bin/gcc /usr/bin/gcc
[root@liuym usr]# ln -s /usr/gcc482/bin/g++ /usr/bin/g++
[root@liuym usr]# gcc -v
Use the built-in specs.
[root@liuyanmin gmp-5.1.3]# make install
0
Goal: i686 - pc - linux - gnu
Configured to
[root@liuyanmin gmp-5.1.3]# make install
1
Thread model: posix
gcc version 4.8.2 (GCC)
Thank you for reading, I hope to help you, thank you for your support of this site!