linux实际问题系列-redhat-linux 裸机离线安装gcc-4.8.5
文章目录
使用场景
新分配了一个服务器,因为部署产品需要依赖gcc环境,但是服务器没有自带gcc,低版本的gcc都没有,不能联网
#以下所有操作都是使用root用户
[root@tyjgbs spark]# gcc
-bash: gcc: command not found
[root@tyjgbs spark]# gcc -v
-bash: gcc: command not found
[root@tyjgbs spark]# gcc -version
-bash: gcc: command not found
一、下载gcc-4.8.5的所有依赖,并上传到指定目录、安装
蓝奏云下载链接 密码:7llh
我自己是上传到了 /usr/gcc/gcc-4.8.5/下
含义:
-i:安装软件包
-U:升级软件,若未软件尚未安装,则安装软件。
-v:表示显示详细信息。
-h:以"#"号显示安装进度。
--force:强制安装
--nodeps:不考虑相依属性的关系
#执行命令 这里因为没有gcc环境,所以用的是-i
[root@uat_kf2_east_dy gcc-4.8.5]# rpm -ivh *.rpm --nodeps --force
warning: cpp-4.8.5-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ########################################### [100%]
1:mpfr ########################################### [ 14%]
2:libmpc ########################################### [ 29%]
3:cpp ########################################### [ 43%]
4:kernel-headers ########################################### [ 57%]
5:glibc-headers ########################################### [ 71%]
6:glibc-devel ########################################### [ 86%]
7:gcc ########################################### [100%]
[root@uat_kf2_east_dy gcc-4.8.5]# gcc -v
gcc: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by gcc)
二、解决 gcc: /lib64/libc.so.6: version `GLIBC_2.14’ not found (required by gcc)
说明安装gcc-8.4.5 需要依赖 GLIBC_2.14
libc.so.6是Linux下的GNU C函数库(glibc),是gcc在编译时默认使用的C函数库
#查看当前使用的glibc版本
[root@uat_kf2_east_dy gcc-4.8.5]# ldd --version
ldd (GNU libc) 2.12
Copyright (C) 2010 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.
Written by Roland McGrath and Ulrich Drepper.
[root@uat_kf2_east_dy gcc-4.8.5]# /lib64/libc.so.6
GNU C Library stable release version 2.12, by Roland McGrath et al.
Copyright (C) 2010 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.
Compiled by GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-17).
Compiled on a Linux 2.6.32 system on 2016-01-28.
Available extensions:
The C stubs add-on version 2.1.2.
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
RT using linux kernel aio
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
发现用的是2.12版本
先看下系统里面装的都是什么版本的
[root@uat_kf2_east_dy gcc-4.8.5]# 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_PRIVATE
发现没有2.14版本,直到这里我想到是:
- 直接安装一个2.14版本,但是机器本身没有gcc,费了大劲,
最后失败!
- 后来又搜到一种方法是将本身2.12版本给升级成2.14版本
2.1 上传升级GLIBC_2.14版本需要的依赖包,安装
我这里上传到了 /usr/gcc/glibc-2.14
[root@uat_kf2_east_dy glibc-2.14]# ll
total 17608
-rw-r--r-- 1 root root 3504537 Nov 25 02:32 glibc-2.14.1-6.x86_64.rpm
-rw-r--r-- 1 root root 11380113 Nov 25 02:32 glibc-common-2.14.1-6.x86_64.rpm
-rw-r--r-- 1 root root 1000813 Nov 25 02:32 glibc-devel-2.14.1-6.x86_64.rpm
-rw-r--r-- 1 root root 612685 Nov 25 02:32 glibc-headers-2.14.1-6.x86_64.rpm
-rw-r--r-- 1 root root 1341813 Nov 25 02:32 glibc-static-2.14.1-6.x86_64.rpm
-rw-r--r-- 1 root root 176137 Nov 25 02:32 glibc-utils-2.14.1-6.x86_64.rpm
[root@uat_kf2_east_dy glibc-2.14]# pwd
/usr/gcc/glibc-2.14
#执行命令 这里因为要升级 glibc-2.12 所以用的是-u
[root@uat_kf2_east_dy glibc-2.14]# rpm -Uvh *.rpm --nodeps --force
warning: glibc-2.14.1-6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 069c8460: NOKEY
Preparing... ########################################### [100%]
1:glibc-common ########################################### [ 17%]
2:glibc warning: /etc/localtime created as /etc/localtime.rpmnew
########################################### [ 33%]
3:glibc-headers ########################################### [ 50%]
4:glibc-devel ########################################### [ 67%]
5:glibc-static ########################################### [ 83%]
6:glibc-utils ########################################### [100%]
#当前glibc版本测试
[root@uat_kf2_east_dy glibc-2.14]# ldd --version
ldd (GNU libc) 2.14.1
Copyright (C) 2011 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.
Written by Roland McGrath and Ulrich Drepper.
#gcc -v 测试
[root@uat_kf2_east_dy glibc-2.14]# 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-28) (GCC)
★★★★★★★成功★★★★★★★★
★ 若本身有低版本的gcc,安装GLIBC_2.14参考 /lib64/libc.so.6: version `GLIBC_2.14’ not found问题归整
★ 若本身有低版本的gcc,想升级gcc版本可以参考linux离线安装 gcc、g++