centos7默认的gcc版本是4.8.5,无奈编译高版本的glibc 2.28,须要降级到gcc 8.2版本
注:gcc高版本和glibc 2.28不兼容
## 查看自带默认的glibcstrings /lib64/lib.so.6 | grep GLIBC# 查看glibc 软件版本号rpm -qa | grep glibc
降级gcc
降级glibc
1. 装置gcc-8.2.0依赖环境
yum install bison -yyum -y install wget bzip2 gcc gcc-c++ glib-headers
2. 降级GNU make到make 4.2
wget http://ftp.gnu.org/gnu/make/make-4.2.1.tar.gztar -zxvf make-4.2.1.tar.gzcd make-4.2.1mkdir buildcd build../configure --prefix=/usr/local/make && make && make installexport PATH=/usr/local/make/bin:$PATHln -s /usr/local/make/bin/make /usr/local/make/bin/gmakemake -v# 昨天应用这段命令装置的wget http://ftp.gnu.org/gnu/make/make-4.2.tar.gztar -xzvf make-4.2.tar.gzcd make-4.2sudo ./configuresudo makesudo make installsudo rm -rf /usr/bin/makesudo cp ./make /usr/bin/make -v
3. 装置Python3.8
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xzxz -d Python-3.8.0.tar.xztar xf Python-3.8.0.tarcd Python-3.8.0./configure --prefix=/usr/local/python3make -j 2 && make installln -s /usr/local/python3/bin/python3 /usr/bin/python3ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
装置python3 make时报错Failed to build these modules: _ctypes
yum install -y libffi-devel
谬误提醒:Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_P
装置libressl
# 下载源码包wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.2.tar.gz# 解压tar -zxvf libressl-3.0.2.tar.gz# 配置装置门路mkdir /usr/local/libresslcd libressl-3.0.2./configure --prefix=/usr/local/libressl# 装置make make install# 创立软连贯代替opensslmv /usr/bin/openssl /usr/bin/openssl.bakmv /usr/include/openssl /usr/include/openssl.bakln -s /usr/local/libressl/bin/openssl /usr/bin/opensslln -s /usr/local/libressl/include/openssl /usr/include/opensslecho /usr/local/libressl/lib >> /etc/ld.so.conf.d/libressl-3.0.2.confldconfig -v# 验证是否装置实现openssl version
谬误提醒:echo权限不够
# 要给echo整条命令加单引号sudo sh -c 'echo /usr/local/libressl/lib >> /etc/ld.so.conf.d/libressl-3.0.2.conf'
谬误提醒:zlib not available
# 装置依赖sudo yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel
4. 装置gcc8.2.0
# 下载并解压wdget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gztar xf gcc-8.2.0.tar.gzcd gcc-8.2.0# 下载gmp mpfr mpc等供编译需要的依赖项./contrib/download_prerequisites# 配置mkdir buildcd build../configure --prefix=/usr/local/gcc-8.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib# 编译装置make -j 2make install# 批改环境变量,使得gcc-8.2.0为默认的gccvi /etc/profile.d/gcc.sh# 导出头文件[yy@localhost profile.d]$ sudo ln -sv /usr/local/gcc-8.2.0/include/ /usr/include/gcc"/usr/include/gcc/include" -> "/usr/local/gcc-8.2.0/include/"
5. 因为之前装置了gcc11.2须要做一下批改
# 利用环境变量echo -e '\nexport PATH=/usr/local/gcc-8.2.0/bin:$PATH\n' >> /etc/profile.d/gcc.shsource /etc/profile.d/gcc.sh# 删除库文件sudo rm /etc/ld.so.conf.d/gcc.conf# 设置库文件touch /etc/ld.so.conf.d/gcc.confchmod 777 /etc/ld.so.conf.d/gcc.conf echo -e "/usr/local/gcc-8.2.0/lib64" >> /etc/ld.so.conf.d/gcc.conf# 加载动静连贯库ldconfig -v# 查看gccldconfig -p |grep gcc# 重启服务器reboot
6. 配置glibc2.28还是报错compiler
# 尝试昨天失败的命令sudo sh -c 'echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile‘
../configure命令胜利
7. 编译
sudo make sudo make install
make install
的报错
能够不必管
8. 验证是否胜利
[yy@localhost build]$ strings /usr/local/gcc-8.2.0/lib64/libstdc++.so.6 | grep GLIBCXX_GLIBCXX_3.4GLIBCXX_3.4.1GLIBCXX_3.4.2GLIBCXX_3.4.3GLIBCXX_3.4.4GLIBCXX_3.4.5GLIBCXX_3.4.6GLIBCXX_3.4.7GLIBCXX_3.4.8GLIBCXX_3.4.9GLIBCXX_3.4.10GLIBCXX_3.4.11GLIBCXX_3.4.12GLIBCXX_3.4.13GLIBCXX_3.4.14GLIBCXX_3.4.15GLIBCXX_3.4.16GLIBCXX_3.4.17GLIBCXX_3.4.18GLIBCXX_3.4.19GLIBCXX_3.4.20GLIBCXX_3.4.21GLIBCXX_3.4.22GLIBCXX_3.4.23GLIBCXX_3.4.24GLIBCXX_3.4.25...[yy@localhost build]$ strings /lib64/libc.so.6 | grep GLIBCGLIBC_2.2.5GLIBC_2.2.6GLIBC_2.3GLIBC_2.3.2GLIBC_2.3.3GLIBC_2.3.4GLIBC_2.4GLIBC_2.5GLIBC_2.6GLIBC_2.7GLIBC_2.8GLIBC_2.9GLIBC_2.10GLIBC_2.11GLIBC_2.12GLIBC_2.13GLIBC_2.14GLIBC_2.15GLIBC_2.16GLIBC_2.17GLIBC_2.18GLIBC_2.22GLIBC_2.23GLIBC_2.24GLIBC_2.25GLIBC_2.26GLIBC_2.27GLIBC_2.28GLIBC_PRIVATE...[yy@localhost build]$ ldd --versionldd (GNU libc) 2.28Copyright (C) 2018 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.Written by Roland McGrath and Ulrich Drepper.