[中间件] 【华为云鲲鹏云服务最佳实践】【工具篇】第027期Gcc-8.3.1安装配置指南


1简介

gcc是GNU编译器套件(GNU Compiler Collection),它包括了CC++Objective-CFortranJavaAdaGo语言D语言的前端,也包括了这些语言的库(如libstdc++、libgcj等等)。GCC的初衷是为GNU操作系统专门编写的一款编译器。GNU系统是彻底的自由软件。此处,“自由”的含义是它尊重用户的自由。 

类别工具

2、基础环境

类别

子项

版本

获取地址(方法)

华为云

虚拟机

KC1(920)

--

OS

CentOS

7.7.1908


Kernel

4.18.0


软件包

 

Gcc

8.3.1

 

https://koji.fedoraproject.org/koji/buildinfo?buildID=1394000

3、组件编译安装

下载Gcc9.1.0源码包并解压

wget https://kojipkgs.fedoraproject.org//packages/gcc/8.3.1/5.fc29/src/gcc-8.3.1-5.fc29.src.rpm

安装rpm源码包,安装后在 ~/rpmbuild 目录下

rpm -ivh gcc-8.3.1-5.fc29.src.rpm

安装依赖

yum install -y yum install -y glibc-static zlib-devel gettext bison flex sharutils texinfo texinfo-tex systemtap-sdt-devel gmp-devel mpfr-devel libmpc-devel python2-devel python3-devel gcc-c++ elfutils-devel gcc-gnat doxygen graphviz texlive-collection-latex python-sphinx docbook5-style-xsl dblatex

解决 dejagnu,isl,isl-devel依赖

wget http://rpmfind.net/linux/fedora/linux/releases/29/Everything/aarch64/os/Packages/d/dejagnu-1.6.1-4.fc29.noarch.rpm

rpm -ivh dejagnu-1.6.1-4.fc29.noarch.rpm

wget http://rpmfind.net/linux/fedora/linux/releases/29/Everything/aarch64/os/Packages/i/isl-0.16.1-7.fc29.aarch64.rpm

rpm -ivh isl-0.16.1-7.fc29.aarch64.rpm

wget http://rpmfind.net/linux/fedora/linux/releases/29/Everything/aarch64/os/Packages/i/isl-devel-0.16.1-7.fc29.aarch64.rpm

rpm -ivh isl-devel-0.16.1-7.fc29.aarch64.rpm

 

编译

rpmbuild -bb ~/rpmbuild/SPECS/gcc.spec

 

编译结果在 ~/rpmbuild/RPMS/ 目录下

image.png

 

 

5、系统配置

    

6、测试

安装

#!/bin/bash

REPO_PATH="/root/rpmbuild/RPMS/"

yum install -y createrepo

if [ $? -ne 0 ]; then
    echo "Failed to install createrepo"
    exit -1;
fi

createrepo ${REPO_PATH}

if [ $? -ne 0 ]; then
    echo "Failed to run createrepo"
    exit -1;
fi

cat <<EOF > /etc/yum.repos.d/gcc8.3.1.repo
[gcc8.3.1]
name=gcc831
baseurl=file://${REPO_PATH}
enabled=1
gpgcheck=0
EOF

yum repolist

yum -y remove gcc gcc-c++

yum -y install --enablerepo gcc8.3.1 gcc gcc-c++

gcc --version

  image.png

7、参考信息

 

8、FAQ 

        


华为云鲲鹏云服务最佳实践 GCC8.3.1 编译安装指南.pdf 398.76 KB,下载次数:1 预览