Linux超详细gcc升级全过程
⽬录
前⾔
1.当前gcc版本
2.安装gcc
4.MPFR编译
5.MPC编译
6.GCC 配置
7.GCC版本更新
前⾔
c c++ 等等需要这个编译器gcc,最近有DBA的朋友咨询RHEL7.6操作系统安装Mysql数据库时需要⾼版本的GCC,研究了下发现坑不少,总结本⽂分享给⼤家
1.当前gcc版本
[root@rhel76 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=dhat/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_at Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
从以上可以看出当前版本为4.8.5,本次我们升级到10.1.0
2.安装gcc
--下载地址:
mirrors.aliyun/gnu/gcc/gcc-10.1.0/
[root@rhel76 ~]# tar -vxf gcc-10.1.
[root@rhel76 gcc-10.1.0]# mkdir build
[root@rhel76 gcc-10.1.0]# cd build/
[root@rhel76 build]# ../configure --prefix=/usr/local/gcc-10.1.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib
checking build x86_64-pc-linux-gnu
checking host x86_64-pc-linux-gnu
checking target x86_64-pc-linux-gnu
checking for a /usr/bin/install -c
checking whether yes
checking whether ln - yes
checking for a sed that does not /usr/bin/sed
checking gawk
checking for yes
checking for yes
checking for yes
checking for yes
checking for yes
checking for yes
checking gcc
checking whether the C yes
checking for C compiler default output a.out
checking for suffix
checking whether we are no
checking for suffix of o
checking whether we are using the GNU yes
checking whether gcc accepts -g... yes
checking for gcc option to accept none needed
checking for g++... g++
checking whether we are using the GNU C++ yes
checking whether g++ accepts -g... yes
bootstrappedchecking whether g++ accepts -static-libstdc++ - no
checking no
checking no
checking whether compiler driver no
checking how to compare cmp --ignore-initial=16 $$f1 $$f2
checking .libs
checking for the correct version of no
configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations. Source code for these libraries can be found at
their respective hosting sites as well as at
/pub/gcc/infrastructure/. See also
/install/prerequisites.html for additional info. If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files. They may be located in separate packages.
从⽇志总可以看出有如下报错,故下⾯每个都安装
configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
[root@jeames007 ~]# tar -vxf gmp-5.0.1.tar.bz2
[root@jeames007 ~]# cd gmp-5.0.1/
[root@jeames007 gmp-5.0.1]# ./configure --prefix=/usr/local/gmp-5.0.1
[root@jeames007 gmp-5.0.1]# make
[root@jeames007 gmp-5.0.1]# make install
make[4]: Leaving directory `/root/gmp-5.0.1'
make[3]: Leaving directory `/root/gmp-5.0.1'
make[2]: Leaving directory `/root/gmp-5.0.1'
make[1]: Leaving directory `/root/gmp-5.0.1'
4.MPFR编译
[root@jeames007 ~]# tar -vxf mpfr-3.1.
[root@jeames007 ~]# cd mpfr-3.1.5/
[root@jeames007 ~]#./configure --prefix=/usr/local/mpfr-3.1.5 --with-gmp=/usr/local/gmp-5.0.1
[root@jeames007 mpfr-3.1.5]# make
[root@jeames007 mpfr-3.1.5]# make install
5.MPC编译
[root@jeames007 ~]# tar -vxf mpc-1.0.
[root@jeames007 ~]# cd mpc-1.0.1
[root@jeames007 ~]# ./configure --prefix=/usr/local/mpc-1.0.1 --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5
[root@jeames007 mpc-1.0.1]# make
[root@jeames007 mpc-1.0.1]# make install
6.GCC 配置
[root@rhel76 ~]# cd gcc-10.1.0
[root@rhel76 gcc-10.1.0]# cd build/
../configure --prefix=/usr/local/gcc-10.1.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-1.0.1 checking build x86_64-pc-linux-gnu
checking host x86_64-pc-linux-gnu
checking target x86_64-pc-linux-gnu
checking for a /usr/bin/install -c
checking whether yes
checking whether ln - yes
checking for a sed that does not /usr/bin/sed
checking gawk
checking for yes
checking for yes
checking for yes
checking for yes
checking for yes
checking for yes
checking gcc
checking whether the C yes
checking for C compiler default output a.out
checking for suffix
checking whether we are no
checking for suffix of o
checking whether we are using the GNU yes
checking whether gcc accepts -g... yes
checking for gcc option to accept none needed
checking for g++... g++
checking whether we are using the GNU C++ yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ - no
checking no
checking no
checking whether compiler driver no
checking how to compare cmp --ignore-initial=16 $$f1 $$f2
checking .libs
checking for the correct version of yes
checking for the correct version of buggy but acceptable
checking for the correct version of yes
checking for the correct version of the gmp/mpfr/ yes
checking for isl 0.15 no
required isl version is 0.15 or later
*** This configuration is not supported in the following subdirectories:
gnattools gotools target-libada target-libhsail-rt target-libphobos target-zlib target-libbacktrace target-libgfortran target-libgo target-libffi target-libobjc target-liboffloadmic
(Any other directories should still work fine.)
checking for default bootstrap-debug
checking for -- no
checking bison -y
checking bison
checking no
checking no
checking m4
checking flex
checking flex
checking no
/root/gcc-10.1.0/missing: line 81: makeinfo: command not found
checking no
checking no
checking ar
checking as
checking no
checking ld
checking no
checking nm
checking ranlib
checking strip
checking no
checking no
checking objcopy
checking objdump
checking no
checking readelf
checking cc
checking for c++... c++
checking gcc
checking gfortran
checking no
checking no
checking no
checking ar
checking no
checking as
checking no
checking no
checking no
checking ld
checking no
checking no
checking no
checking nm
checking no
checking objcopy
checking no
checking objdump
checking no
checking no
checking no
checking ranlib
checking no
checking readelf
checking no
checking strip
checking no
checking no
checking no
checking no
checking where to find the host tool
checking where to find the host tool
checking where to find the just compiled
checking where to find the target c++... just compiled
checking where to find the target c++ for libstdc++... just compiled
checking where to find the host tool
checking where to find the just compiled
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking where to find the host tool
checking whether to enable maintainer-specific portions no
configure: creating ./config.status
config.status: creating Makefile
[root@jeames007 ~]# make -j4
make 时间很长,很长,耐⼼等待,本⼈编译了1个⼩时。所以有条件的话,在编译时,可以使⽤make -j8
[root@jeames007 build]# make install
此时GCC版本还未更新下,需要以下的操作
7.GCC版本更新
mv /usr/bin/gcc /usr/bin/gcc485
mv /usr/bin/g++ /usr/bin/g++485
mv /usr/bin/c++ /usr/bin/c++485
mv /usr/bin/cc /usr/bin/cc485
ln -s /usr/local/gcc-10.1.0/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc-10.1.0/bin/g++ /usr/bin/g++
ln -s /usr/local/gcc-10.1.0/bin/c++ /usr/bin/c++
ln -s /usr/local/gcc-10.1.0/bin/gcc /usr/bin/cc
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
ln -s /usr/local/gcc-10.1.0/lib64/libstdc++.so.6.0.28 /usr/lib64/libstdc++.so.6
脚本执⾏成功之后就可以查看当前使⽤的gcc版本了查看的命令:gcc -v
[root@jeames007 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-10.1.0/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/usr/local/gcc-10.1.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-1.0.1 Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.1.0 (GCC)
到此这篇关于Linux超详细gcc升级全过程的⽂章就介绍到这了,更多相关Linux gcc升级内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论