源码编译glibc-2.17

编译安装glic2.17步骤
1.查看有哪些gibc版本可用

strings /lib64/libc.so.6 |grep GLIBC

2.下载glic2.17的版本源码包
网址:http://ftp.gnu.org/gnu/glibc/
glibc-2.17.tar.gz 2012-12-25 16:10 22M

3.编译步骤如下

# tar -zxvf glibc-2.17.tar.gz

# cd glibc-2.17

# mkdir build

# cd build/

# ../configure --prefix=/opt/glibc-2.17

到这一步报错:

checking for as... as
checking version of as... 2.17.50.0.6, bad
checking for ld... ld
checking version of ld... 2.17.50.0.6, bad

configure: error: 
*** These critical programs are missing or too old: as ld gcc
*** Check the INSTALL file for required versions.

这是由于binutils版本过低导致的,查看已部署版本

# ld -v
GNU ld version 2.17.50.0.6-6.el5 20061020

4.下载binutils的源码包,进行编译升级

http://ftp.gnu.org/gnu/binutils/
版本:binutils-2.34.tar.gz
# tar -zxvf binutils-2.34.tar.gz
# cd binutils-2.34
# ./configure --prefix=/usr/local/binutils
# make && make install

查看是否安装成功
# cd /usr/local/binutils/bin/
# ./ld -v
# ./as -v

备份
# mv /usr/bin/{ld,ld_bak}
# mv /usr/bin/{as,as_bak}

创建软连接
# ln -s /usr/local/binutils/bin/ld /usr/bin/ld
# ln -s /usr/local/binutils/bin/as /usr/bin/as
# ld -v
GNU ld (GNU Binutils) 2.34
# as -v
GNU assembler version 2.34 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.34

5.继续glibc编译

# cd glibc-2.17/build/
# ../configure --prefix=/opt/glibc-2.17

报错:

configure: error: 
*** These critical programs are missing or too old: gcc
*** Check the INSTALL file for required versions.

继续安装gcc呗

6.安装gcc

http://ftp.gnu.org/gnu/gcc/gcc-4.8.5/
# tar -zxvf gcc-4.8.5.tar.gz
# cd gcc-4.8.5
# ./contrib/download_prerequisites

# ./contrib/download_ecj
# cd ..
# mkdir objdir 
# cd objdir
# ../gcc-4.8.5/configure
这里为了加快速度,要采用多核编译,查看当前系统有几核
# cat /proc/cpuinfo (cpu cores显示的就是核数)


# make (时间很长,大概一个多小时)
# make install

在一些博客下面会提示:(据说不能再源码目录下编译,否则会出现configure: error: source directory already configured; run “make distclean” there first,),但是根据我的操作来看,没有执行# ./contrib/download_ecj
才会包这样的错误,无论在哪个目录执行,重点是不要忘记执行这一步的安装步骤。

7.继续glibc编译

# cd glibc-2.17/build/
# ../configure --prefix=/opt/glibc-2.17

你可能感兴趣的:(linux,linux)