华为鲲鹏服务器gcc升级到7.3.0版本

一、首先检查gcc的版本

进入控制台终端执行gcc --version或g++ -v

[root@localhost ~]# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/4.8.5/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-aarch64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-aarch64-redhat-linux/cloog-install --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

二、安装gcc7.3.0

本文以7.3.0版本为例。
当查询到的版本不满足要求时,需要安装gcc。
下载gcc7.3.0:https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz

下载完成后,将“gcc-7.3.0.tar.gz”放置于“/home”目录下,并解压安装。

cd /home
tar -xvf gcc-7.3.0.tar.gz

三、下载isl、gmp、mpc、mpfr

1、在“gcc-7.3.0”目录下,检查gcc的依赖包是否已下载和安装。

./contrib/download_prerequisites

2、根据需要,下载
“gmp-6.1.0.tar.bz2”
“isl-0.16.1.tar.bz2”
“mpc-1.0.3.tar.gz”
“mpfr-3.1.4.tar.bz2”。
在步骤3.1中检查到存在上述依赖包未下载安装时,请根据需要执行相应的命令下载。

wget https://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
wget https://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
wget https://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2

3、 将安装包放置于“/home/gcc-7.3.0”目录下。
4、 把下载好的安装包解压并安装,进入解压后的目录执行

./configure
make
make install

四、编译安装gcc

1、编译gcc。
“-j”参数可利用多核CPU加快编译速度,在本示例中,使用的是16核CPU,所以此处为“-j16”。
可通过下述命令查询CPU核数:

cat /proc/cpuinfo| grep "processor"| wc -l
cd /home/gcc-7.3.0
mkdir gcc-build-7.3.0
cd gcc-build-7.3.0
../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr
make -j16

2、执行安装。

make install

3、 确定“libstdc++.so”是在“/usr/lib64”目录下。

[root@localhost rz]# cd /usr/lib64/
[root@localhost lib64]# ll | grep libstdc++.so
lrwxrwxrwx.  1 root root       19 Dec  8 14:05 libstdc++.so -> libstdc++.so.6.0.24
lrwxrwxrwx.  1 root root       19 Dec  8 14:05 libstdc++.so.6 -> libstdc++.so.6.0.24
-rwxr-xr-x.  1 root root  1057320 Sep 30 10:40 libstdc++.so.6.0.19
-rwxr-xr-x.  1 root root 11836224 Dec  8 14:05 libstdc++.so.6.0.24
-rw-r--r--.  1 root root     2385 Dec  8 14:05 libstdc++.so.6.0.24-gdb.py

4、确定软连接存在

[root@localhost lib64]# cd /usr/lib64/
[root@localhost lib64]# ll |grep libstdc++.so.6.0.24
lrwxrwxrwx.  1 root root       19 Dec  8 14:05 libstdc++.so -> libstdc++.so.6.0.24
lrwxrwxrwx.  1 root root       19 Dec  8 14:05 libstdc++.so.6 -> libstdc++.so.6.0.24
-rwxr-xr-x.  1 root root 11836224 Dec  8 14:05 libstdc++.so.6.0.24
-rw-r--r--.  1 root root     2385 Dec  8 14:05 libstdc++.so.6.0.24-gdb.py

5、查看版本
gcc --version

[root@localhost ERtpServer]# gcc --version
gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.

五、遇到的问题

1、出现了如“error while loading shared libraries: libisl.so.15: cannot open shared object file: No such file or directory”的错误
原因分析
编译过程中找不到libisl.so.15库文件。
处理步骤
步骤 1 执行以下命令,设置软链接。

ln -s /usr/local/lib/libisl.so.15 /usr/lib64/libisl.so.15
ldconfig

步骤 2 重新执行make

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值