欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

CentOS 源码升级 gcc和gdb

程序员文章站 2022-03-18 22:37:04
CentOS 源码升级 gcc和gdb系统环境OS : CentOS 7.8GCC : 4.8.5GDB : 7.6.1升级目标GCC : 9.3GDB : 9.2获取源码源码下载完成后, 目录结构如下gcc |__gcc-9.3.0.tar.gz |__gmp-6.2.0.tar.bz2 |__mpc-1.2.1.tar.gz |__mpfr-4.1.0.tar.bz2gdb |__gdb-...

CentOS 源码升级 gcc和gdb

系统环境

  • OS : CentOS 7.8
  • GCC : 4.8.5
  • GDB : 7.6.1

升级目标

  • GCC : 9.3
  • GDB : 9.2

获取源码

源码下载完成后, 目录结构如下

gcc
    |__gcc-9.3.0.tar.gz  
    |__gmp-6.2.0.tar.bz2 
    |__mpc-1.2.1.tar.gz
    |__mpfr-4.1.0.tar.bz2

gdb
    |__gdb-9.2.tar.gz

编译安装

install gmp from source

tar -xjf gmp-6.2.0.tar.bz2
cd       gmp-6.2.0  
./configure --prefix=$(pwd)/../gmp --enable-shared=no
make && make install

install mpfr from source

tar -xjf mpfr-4.1.0.tar.bz2
cd       mpfr-4.1.0
./configure --prefix=$(pwd)/../mpfr --enable-shared=no                      \
            --with-gmp=$(pwd)/../gmp
make && make install 

install mpc from source

tar -xzf mpc-1.2.1.tar.gz
cd mpc-1.2.1
./configure --prefix=$(pwd)/../mpc --enable-shared=no                       \
            --with-gmp=$(pwd)/../gmp --with-mpfr=$(pwd)/../mpfr
make && make install

install gcc from source

tar -xjf gcc-9.3.0.tar.bz2
cd gcc-9.3.0
./configure --prefix=/usr/local/gcc --enable-languages=c,c++                \
            --with-gmp=$(pwd)/../gmp                                        \
            --with-mpfr=$(pwd)/../mpfr                                      \
            --with-mpc=$(pwd)/../mpc --disable-multilib

make && sudo make install
ln -s /usr/local/gcc/bin/gcc /usr/local/bin/gcc
ln -s /usr/local/gcc/bin/g++ /usr/local/bin/g++

install gdb from source

sudo yum -y install texinfo
tar -xzf gdb-9.2.tar.gz
mkdir build && cd build  
 $(pwd)/../gdb-9.2/configure --prefix=/usr/local/gdb
make && sudo make install
sudo ln -s /usr/local/gdb/bin/gdb /usr/local/bin/gdb

本文地址:https://blog.csdn.net/do_er/article/details/109616593