环境
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、运行命令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



