gcc-8.3.1安装(arm,Centos7)

环境
Centos7(Red Hat 8.3.1-3)
arm cpu

参考官网链接

一、简要步骤:

1、修改yum的Base源为国内源(比如清华源
2、make yum makecache
3、安装CentOS SCLo RH仓库(yum install centos-release-scl-rh)
4、安装yum包yum install devtoolset-8
5、设置默认gcc编译器(source /opt/rh/devtoolset-8/enable)
6、测试(gcc -v,g++ -v)

二、详细步骤

1、修改yum的Base源为清华源,注意选arm的(centos-altarch镜像),默认是x86的
附上文件CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-altarch/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos-altarch.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-altarch/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos-altarch.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-altarch/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos-altarch.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centos-altarchplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-altarch/$releasever/centos-altarchplus/$basearch/
#mirrorlist=http://mirrorlist.centos-altarch.org/?release=$releasever&arch=$basearch&repo=centos-altarchplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

2、运行命令sudo make yum makecache
3、安装CentOS SCLo RH仓库,参考链接

yum install centos-release-scl-rh

在这里插入图片描述

在这里插入图片描述
4、安装yum包

yum install devtoolset-8-gcc-plugin-devel

安装成功的参考截图如下
在这里插入图片描述

5、设置默认的编译器

# scl enable devtoolset-8 bash
bash-4.2# gcc -v

6、测试

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-aarch64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)

7、写入配置文件,自动切换编译器

echo "source /opt/rh/devtoolset-8/enable" > ~/.bashrc

猜你喜欢

转载自blog.csdn.net/qq_29809823/article/details/121055321