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及大數據 電子書】

在這裏插入圖片描述

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