查看当前系统的glibc库
strings /lib64/libc.so.6 |grep GLIBC
相关命令
# 查看系统名称
uname -a
# 查看系统centos的版本
cat /etc/redhat-release
# 查看系统版本
cat /proc/version
# 查看系统内核
rpm -qa | grep kernel
按照步骤升级centos7的glibc库到glibc-2.28
下载安装包
# 升级glibc需要的依赖
wget https://ftp.gnu.org/gnu/binutils/binutils-2.32.tar.gz
wget https://ftp.gnu.org/gnu/bison/bison-3.2.1.tar.gz
wget https://ftp.gnu.org/pub/gnu/make/make-4.3.tar.gz
# 升级gcc需要的依赖
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl.0.18.tar.bz2
# gcc-8.2.0安装包
wget https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz
# glibc-2.28安装包
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
安装binutils
# 解压
tar -xzvf binutils-2.32.tar.gz
# 安装
cd binutils-2.32/
./configure --prefix=/usr/local/binutils-2.32
make
make install
#进入binutils ,并查看 安装版本是否可用
cd /usr/local/binutils-2.32/bin
./ld --version
./as --version
#备份原有的binutils
mv /usr/bin/ld /usr/bin/ld_bak
mv /usr/bin/as /usr/bin/as_bak
#将新的软链接方式写入
ln -s /usr/local/binutils-2.32/bin/ld /usr/bin/ld
ln -s /usr/local/binutils-2.32/bin/as /usr/bin/as
安装bison
# 解压
tar -xf bison-3.2.1.tar.gz
# 安装
cd bison-3.2.1
./configure --prefix=/usr/local/bison-3.2.1
make
make install
# 备份原有的bison
mv /usr/bin/bison /usr/bin/bison_bak
# 将新的软链接方式写入
ln -s /usr/local/bison-3.2.1/bin/bison /usr/bin/bison
安装make
# 解压
tar -zxvf make-4.3.tar.gz
# 安装
cd make-4.3
./configure --prefix=/usr/local/make-4.3
make
make install
# 备份原有的make
mv /usr/bin/make /usr/bin/make_bak
# 将新的软链接方式写入
ln -s /usr/local/make-4.3/bin/make /usr/bin/make
安装gmp
# 解压
tar -jxvf gmp-6.1.0.tar.bz2
# 安装
cd gmp-6.1.0
./configure --prefix=/usr/local/gmp
make && make install
注意:如果在执行./configure --prefix=/usr/local/gmp报错:error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons).,说明没有安装m4,使用 yum install m4,然后再执行即可!
安装mpfr
# 解压
tar -jxvf mpfr-3.1.4.tar.bz2
# 安装
cd mpfr-3.1.4
./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp
make && make install
安装mpc
# 解压
tar -zxvf mpc-1.0.3.tar.gz
# 安装
cd mpc-1.0.3
./configure --prefix=/usr/local/mpc --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr
make && make install
安装isl
# 解压
tar -jxvf isl.0.18.tar.bz2
# 安装
cd isl.0.18
./configure --prefix=/usr/local/isl --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr --with-mpc=/usr/local/mpc
make && make install
注意:这时候会报错 configure: error: gmp library not found ,使用:yum install gmp-devel.x86_64
安装即可
安装gcc
# 解压
tar -zxvf gcc-8.2.0.tar.gz
# 安装
cd gcc-8.2.0
# 安装gcc不能直接在安装包中执行configure,需要创建build文件夹
mkdir build
cd build
# 执行
../configure --prefix=/usr/local/gcc-8.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gmp/ --with-mpfr=/usr/local/mpfr/ --with-mpc=/usr/local/mpc/ --with-isl=/usr/local/isl
# 时间比较长,采用 -j4
make -j4
make install
# 备份原有的gcc
mv /usr/bin/gcc /usr/bin/gcc_bak
# 将新的软链接方式写入
ln -s /usr/local/gcc-8.2.0/bin/gcc /usr/bin/gcc
注意:报错
error while loading shared libraries: libisl.so.15: cannot open shared object,执行一下
vim ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/isl/lib:$LD_LIBRARY_PATH
source ~/.bashrc
检查一下gcc版本是否是8.2.0
gcc -v
安装glibc
# 解压
tar xvf glibc-2.28.tar.gz
# 安装
cd glibc-2.28
# 同样需要创建build文件夹,再执行configure
mkdir build
cd ./build
# 执行
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
# 时间较长,使用 -j4
make -j4
make install
注意:报错
LD_LIBRARY_PATH shouldn't contain the current directory when, 执行一下
# 执行export,设置环境变量为空
export LD_LIBRARY_PATH=
# 重新执行configure,这时候还是会报错,又将值重置回来
export LD_LIBRARY_PATH=/usr/local/isl/lib
检查一下glibc是否升级2.28
strings /lib64/libc.so.6 |grep GLIBC-2.28