glibc 2.17升级2.28,gcc 4.8.5升级9.2.0,GNU Make 3.82 升级到4.2.1,安装bison

大家好,我是后来,我会分享我在学习和工作中遇到的点滴,希望有机会我的某篇文章能够对你有所帮助,所有的文章都会在公众号首发,欢迎大家关注我的公众号" 后来X大数据 ",感谢你的支持与认可。

因为要在centos7 安装mysql8,在安装的时候遇到了这个鬼问题,头疼

# 安装mysql
rpm -ivh mysql-*.rpm

[root@bigdata101 mysql-lib]# rpm -ivh mysql-community-client-8.0.19-1.el8.x86_64.rpm
warning: mysql-community-client-8.0.19-1.el8.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
	libc.so.6(GLIBC_2.28)(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libcrypto.so.1.1()(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libcrypto.so.1.1(OPENSSL_1_1_1)(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libncurses.so.6()(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libssl.so.1.1()(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libssl.so.1.1(OPENSSL_1_1_0)(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libssl.so.1.1(OPENSSL_1_1_1)(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libstdc++.so.6(CXXABI_1.3.9)(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libstdc++.so.6(GLIBCXX_3.4.20)(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libstdc++.so.6(GLIBCXX_3.4.21)(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	libtinfo.so.6()(64bit) is needed by mysql-community-client-8.0.19-1.el8.x86_64
	mysql-community-libs(x86-64) >= 8.0.11 is needed by mysql-community-client-8.0.19-1.el8.x86_64

最后的问题发现:我太傻逼了,最后找到了问题的根源: 需要的是centos7 的mysql8,下的版本却是centos 8 的mysql 包,大家看看el后面的数字。和自己centos版本要一样啊。这问题太羞耻了。

但是下面的glibc 2.17升级2.28的内容还是可以的。

glibc 2.17升级2.28

# 查一下我的glibc版本:

[root@bigdata101 glibc-2.28]# strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_PRIVATE

然后我就去官网下载了Glibc2.28打算安装,官网地址:http://ftp.gnu.org/gnu/glibc/(选择你想要的版本)

# 完整步骤:
tar -xf glibc-2.28.tar.gz
cd glibc-2.28
mkdir build; cd build

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin 

make 
make install # 这一步的2个问题可以忽略

ls -l /lib64/libc.so.6

# 最后来看看我们的结果吧
strings /lib64/libc.so.6 | grep GLIBC
.....
GLIBC_2.26
GLIBC_2.27
GLIBC_2.28
GLIBC_PRIVATE

我的具体执行过程,以及报错修复

# 解压安装:
tar -xf glibc-2.28.tar.gz
cd glibc-2.28
mkdir build; cd build

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin  # 运行到这一步后就报错了,报错图如下图
# (如果这一步没报错的,大家可以直接往下翻,找到我继续安装glibc的过程)

事情并不顺利,它对应的gcc等版本也需要升级,所以就开始我的升级之路。以下截图是我glibc 2.28安装的报错
在这里插入图片描述
通过上面的报错,看到很多显示no和bad信息的都是版本不够

升级之前希望大家能打开INSTALL文件看一下,glibc建议大家安装的各插件版本 不要和我犯一样的错误,自以为是的安装了gcc新版本9.2.0,然而版本太新依然用不了还是报错。最后我还是安装了gcc8.2.0,安装步骤和下面的9.2.0是一样的

1. gcc版本不够,那就升级它,原来是4.8.5,给它升级到9.2.0

gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)


yum -y install wget bzip2 gcc gcc-c++ glibc-headers

# 下载gcc包到自己的目录,-P后面的下载目录自己指定
# 下载这个文件可以直接去官网下,反而更快一些,
# 下载地址:https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc(自己选择版本)
wget -c -P /opt/software/ https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz

# 解压
cd /opt/software/
tar -zxvf gcc-9.2.0.tar.gz
# 解压要好久,可以喝杯茶放松一下

cd gcc-9.2.0
./contrib/download_prerequisites    #下载gmp mpfr mpc等供编译需求的依赖项
# 结果如下:
2020-07-01 10:47:47 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1]
2020-07-01 10:48:26 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4.tar.bz2" [1]
2020-07-01 10:48:41 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./mpc-1.0.3.tar.gz" [1]
2020-07-01 10:49:31 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291] -> "./isl-0.18.tar.bz2" [1]
gmp-6.1.0.tar.bz2: OK
mpfr-3.1.4.tar.bz2: OK
mpc-1.0.3.tar.gz: OK
isl-0.18.tar.bz2: OK
All prerequisites downloaded successfully.

# 不能在source目录下configure,必须在上一层的目录下
mkdir build
cd bulid

../configure --prefix=/usr/local/gcc-9.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib
# 结果如下
checking where to find the target ar... host tool
checking where to find the target as... host tool
checking where to find the target cc... just compiled
checking where to find the target c++... just compiled
checking where to find the target c++ for libstdc++... just compiled
checking where to find the target dlltool... host tool
checking where to find the target gcc... just compiled
checking where to find the target gfortran... host tool
checking where to find the target gccgo... host tool
checking where to find the target gdc... host tool
checking where to find the target ld... host tool
checking where to find the target lipo... host tool
checking where to find the target nm... host tool
checking where to find the target objcopy... host tool
checking where to find the target objdump... host tool
checking where to find the target otool... host tool
checking where to find the target ranlib... host tool
checking where to find the target readelf... host tool
checking where to find the target strip... host tool
checking where to find the target windres... host tool
checking where to find the target windmc... host tool
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile

# 执行make,这个时间太长了,我大概用了不到4小时,我也不知道它在干啥,完全可以大家在中午吃饭前开始跑,或许午休后就可以了
make
# 结果:
make[4]: 离开目录“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”
make[3]: 离开目录“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”
make[2]: 离开目录“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”
make[1]: 离开目录“/opt/tmp/gcc-9.2.0/build”

# 接下来安装它
make install
# 结果:
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/opt/software/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic'
make[3]: Leaving directory `/opt/software/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic'
make[2]: Leaving directory `/opt/software/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic'
make[1]: Leaving directory `/opt/software/gcc-9.2.0/build'

# 写配置文件
echo -e '\nexport PATH=/usr/local/gcc-9.2.0/bin:$PATH\n' >> /etc/profile.d/gcc.sh && source /etc/profile.d/gcc.sh

# 导出头文件
ln -sv /usr/local/gcc-9.2.0/include/ /usr/include/gcc
# 结果:
	libgcc_s.so.1 -> libgcc_s-4.8.5-20150702.so.1
	libutil.so.1 -> libutil-2.17.so
/lib/sse2: (hwcap: 0x0000000004000000)
/lib64/sse2: (hwcap: 0x0000000004000000)
/lib64/tls: (hwcap: 0x8000000000000000)

#配置生效
ldconfig -v    
# 结果:

# 导出验证
ldconfig -p |grep gcc
# 结果:
libgcc_s.so.1 (libc6,x86-64) => /lib64/libgcc_s.so.1

# 查看版本
gcc -v
# 结果:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-9.2.0/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/usr/local/gcc-9.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 9.2.0 (GCC)

2. GNU Make版本从3.82 升级到4.2.1

make -v

GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

make 官方下载地址:https://ftp.gnu.org/gnu/make/

# 解压
tar -zxvf make-4.2.1.tar.gz

# 安装
cd make-4.2.1
# 建立编译目录
mkdir build
cd build
# 执行
../configure --prefix=/usr

# 执行完,这里需要编译,会生成build.sh文件,然后执行这个文件
sh build.sh
# 然后安装
make install

# 然后就安装完成了,查看版本
make -v
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

3. 安装bison

先看版本:

bison -V
bash: bison: command not found
 bison -v
bash: bison: command not found

这就是没装啊,那就直接yum安装吧:

yum install -y bison

在这里插入图片描述
再来看看版本:

bison --version
bison (GNU Bison) 3.0.4
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

好了,继续搞glibc走起

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

在这里插入图片描述
结果非常惊喜,没有报错啦。那就继续吧

make 

结果又是一个报错,心态要奔了
在这里插入图片描述

./../include/libc-symbols.h:534:26: error: ‘__EI___errno_location’ specifies less restrictive attributes than its target ‘__errno_location’: ‘const’, ‘nothrow’ [-Werror=missing-attributes]
  534 |   extern __typeof (name) __EI_##name \
      |                          ^~~~~
./../include/libc-symbols.h:538:29: note: in expansion of macro ‘__hidden_ver1’
  538 | #  define hidden_def(name)  __hidden_ver1(__GI_##name, name, name);
      |                             ^~~~~~~~~~~~~
./../include/libc-symbols.h:602:32: note: in expansion of macro ‘hidden_def’
  602 | # define libc_hidden_def(name) hidden_def (name)
      |                                ^~~~~~~~~~
errno-loc.c:28:1: note: in expansion of macro ‘libc_hidden_def’
   28 | libc_hidden_def (__errno_location)
      | ^~~~~~~~~~~~~~~
errno-loc.c:24:1: note: ‘__EI___errno_location’ target declared here
   24 | __errno_location (void)
      | ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [../o-iterator.mk:9: /opt/module/mysql-lib/glibc-2.28/build/csu/errno-loc.os] Error 1
make[2]: Leaving directory '/opt/module/mysql-lib/glibc-2.28/csu'
make[1]: *** [Makefile:258: csu/subdir_lib] Error 2
make[1]: Leaving directory '/opt/module/mysql-lib/glibc-2.28'
make: *** [Makefile:9: all] Error 2

经过我又重装了gcc 8.2.0,这个问题终于消失了。

make install

# 结果
LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /opt/module/mysql-lib/glibc-2.28/build/
/usr/bin/ld: cannot find -lnss_test2
collect2: error: ld returned 1 exit status
Execution of gcc -B/usr/bin/ failed!
The script has found some problems with your installation!
Please read the FAQ and the README file and check the following:
- Did you change the gcc specs file (necessary after upgrading from
  Linux libc5)?
- Are there any symbolic links of the form libXXX.so to old libraries?
  Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,
  libm.so should point to the newly installed glibc file - and there should be
  only one such link (check e.g. /lib and /usr/lib)
You should restart this script from your build directory after you've
fixed all problems!
Btw. the script doesn't work if you're installing GNU libc not as your
primary library!
make[1]: *** [Makefile:111: install] Error 1
make[1]: Leaving directory '/opt/module/mysql-lib/glibc-2.28'
make: *** [Makefile:12: install] Error 2

# 这上面的问题可以忽略

ls -l /lib64/libc.so.6

# 最后来看看我们的结果吧
strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_2.24
GLIBC_2.25
GLIBC_2.26
GLIBC_2.27
GLIBC_2.28
GLIBC_PRIVATE

glibc升级成功。

扫码关注公众号“后来X大数据”,回复【电子书】,领取超多本pdf 【java及大数据 电子书】

在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章