centos7 安装 gcc-6.2.0

来源:互联网 发布:双11淘宝活动方案 编辑:程序博客网 时间:2024/06/07 12:18

1. 下载 gcc-6.2.0 源码包,可以直接从 GCC 的FTP 上下载,随后解压

    并从 contrib/download_prerequisites 文件内查看需要的依赖包

[root@node1 software]# tar -zvxf gcc-6.2.0.tar.gz

[root@node1 software]# cd gcc-6.2.0/

[root@node1 contrib]# vim contrib/download_prerequisites


下载依赖包

[root@node1 software]# wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2 

[root@node1 software]# wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2

[root@node1 software]# wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz


2. 安装 gmp

[root@node1 software]# bzip2 -d gmp-4.3.2.tar.bz2

[root@node1 software]# tar xvf gmp-4.3.2.tar

[root@node1 software]# cd gmp-4.3.2/

[root@node1 gmp-4.3.2]# ./configure --prefix=/opt/gcc-6.2.0

[root@node1 gmp-4.3.2]# make -j  //没问题

[root@node1 gmp-4.3.2]# make check //出错 参考http://www.linuxdiyf.com/linux/26770.html


......
/bin/sh: line 4: 182326 Segmentation fault      (core dumped) ${dir}$tst
FAIL: t-scan
......
====================================
1 of 58 tests failed
Please report to gmp-bugs@gmplib.org
====================================
make[4]: *** [check-TESTS] Error 1
make[4]: Leaving directory `/home/huangx/hx/software/gmp-4.3.2/tests/mpz'
make[3]: *** [check-am] Error 2
make[3]: Leaving directory `/home/huangx/hx/software/gmp-4.3.2/tests/mpz'
make[2]: *** [check-recursive] Error 1
make[2]: Leaving directory `/home/huangx/hx/software/gmp-4.3.2/tests'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/home/huangx/hx/software/gmp-4.3.2'
make: *** [check] Error 2
}
[root@node1 gmp-4.3.2]# vim config.log


[root@node1 gmp-4.3.2]# make install //好像说make check 出问题也没问题,只要make没错就可以,所以直接install
{
make  install-data-hook
make[4]: Entering directory `/home/huangx/hx/software/gmp-4.3.2'
make[4]: Warning: File `Makefile' has modification time 24640 s in the future


+-------------------------------------------------------------+
| CAUTION:                                                    |
|                                                             |
| If you have not already run "make check", then we strongly  |
| recommend you do so.                                        |
|                                                             |
| GMP has been carefully tested by its authors, but compilers |
| are all too often released with serious bugs.  GMP tends to |
| explore interesting corners in compilers and has hit bugs   |
| on quite a few occasions.                                   |
|                                                             |
+-------------------------------------------------------------+


make[4]: warning:  Clock skew detected.  Your build may be incomplete.
make[4]: Leaving directory `/home/huangx/hx/software/gmp-4.3.2'
make[3]: warning:  Clock skew detected.  Your build may be incomplete.
make[3]: Leaving directory `/home/huangx/hx/software/gmp-4.3.2'
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
make[2]: Leaving directory `/home/huangx/hx/software/gmp-4.3.2'
make[1]: warning:  Clock skew detected.  Your build may be incomplete.
make[1]: Leaving directory `/home/huangx/hx/software/gmp-4.3.2'
make: warning:  Clock skew detected.  Your build may be incomplete.


3. 安装 mpfr

[root@node1 gmp-4.3.2]# cd ..

[root@node1 software]# bzip2 -d mpfr-2.4.2.tar.bz2

[root@node1 software]# tar xvf mpfr-2.4.2.tar

[root@node1 software]# cd mpfr-2.4.2/

[root@node1 mpfr-2.4.2]# ./configure --prefix=/opt/gcc-6.2.0

[root@node1 mpfr-2.4.2]# ./configure --prefix=/opt/gcc-6.2.0 --with-gmp=/opt/gcc-6.2.0

[root@node1 mpfr-2.4.2]# make

[root@node1 mpfr-2.4.2]# make install


4. 安装 mpc

[root@node1 mpfr-2.4.2]# cd ..

[root@node1 software]# tar xvf mpc-0.8.1.tar.gz

[root@node1 software]# cd mpc-0.8.1/

[root@node1 mpc-0.8.1]# ./configure --prefix=/opt/gcc-6.2.0 --with-gmp=/opt/gcc-6.2.0 --with-mpfr=/opt/gcc-6.2.0

[root@node1 mpc-0.8.1]# make -j

[root@node1 mpc-0.8.1]# make install


5. 安装 gcc

[root@node1 mpc-0.8.1]# cd ..

[root@node1 software]# cd gcc-6.2.0/

[root@node1 gcc-6.2.0]# mkdir build

[root@node1 gcc-6.2.0]# cd build/

[root@node1 build]# ../configure --prefix=/opt/gcc-6.2.0 --with-gmp=/opt/gcc-6.2.0 --with-mpfr=/opt/gcc-6.2.0 --with-mpc=/opt/gcc-6.2.0 -enable-checking=release -enable-languages=c,c++ -disable-multilib

[root@node1 build]# make

[root@node1 build]# make install


6. 设置环境变量

[root@node1 software]# export PATH=/opt/gcc-6.2.0/bin:$PATH

[root@node1 software]# export LD_LIBRARY_PATH=/opt/gcc-6.2.0/lib:$LD_LIBRARY_PATH


7. 查看gcc版本

[root@node1 ~]# gcc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/opt/gcc-6.2.0/libexec/gcc/x86_64-pc-linux-gnu/6.2.0/lto-wrapper

Target: x86_64-pc-linux-gnu

Configured with: ../configure --prefix=/opt/gcc-6.2.0 --with-gmp=/opt/gcc-6.2.0 --with-mpfr=/opt/gcc-6.2.0 --with-mpc=/opt/gcc-6.2.0 -enable-checking=release -enable-languages=c,c++ -disable-multilib

Thread model: posix

gcc version 6.2.0 (GCC)



参考 http://blog.csdn.net/stormbjm/article/details/9107831

0 0
原创粉丝点击