源碼編譯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

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