Redhat5默認安裝glibc版本是2.5,想要更新到glibc-2.9。從gnu網址下載glibc-2.9,解壓后可以從中找到文件INSTALL和FAQ。
INSTALL講解安裝過程,FAQ講解常見的問題。
INSTALL講解安裝過程,FAQ講解常見的問題。
安裝環境為:redhat5,gcc-4.1.2,原始glib-2.5
安裝過程如下:
1、查看redhat系統glibc版本,直接執行libc.so.6文件即可得知。
# /lib/libc.so.6
2、INSTALL文件里說明了安裝該版本的glibc的前提條件,安裝前需要仔細查看。
3、configure過程
glibc不允許在源碼目錄樹下編譯,必須新建一個目錄來configure和build,這樣一旦出錯就將整個目錄移除即可。
# cd /home/glibc-2.9 //glibc-2.9源文件目錄
# cd ../
# mkdir glibc-2.9-build //新建的用於configure和build的目錄
# cd /home/glibc-2.9-build //此時,我們處於glibc-2.9-build目錄下
# cd ../
# mkdir glibc-2.9-build //新建的用於configure和build的目錄
# cd /home/glibc-2.9-build //此時,我們處於glibc-2.9-build目錄下
configure有很多選項,但是需要制定的是prefix,用於指定glibc安裝的位置,默認是安裝在/usr/lcoal下
glibc強烈建議不要安裝到這個目錄下,而是改為--prefix=/usr,這會將glibc安裝為linux系統的標准庫。
---------------------------------------------------------------------------
glibc強烈建議不要安裝到這個目錄下,而是改為--prefix=/usr,這會將glibc安裝為linux系統的標准庫。
---------------------------------------------------------------------------
`configure' takes many options, but the only one that is usually mandatory is `--prefix'. This option tells `configure' where you want glibc installed. This defaults to `/usr/local', but the normal setting to install as the standard system library is `--prefix=/usr' for GNU/Linux systems.
# ../glibc-2.9/configure --prefix=/usr
4、make過程
在make之前需要指明系統cpu型號,否則可能出現如下錯誤:
------------------------------------------------------
------------------------------------------------------
/root/source/glibc-build/libc_pic.os:/root/source/glibc-2.7/nscd/nscd_gethst_r.c:400: more undefined references to `__sync_fetch_and_add_4' follow
/root/source/glibc-build/libc_pic.os: In function `__nscd_get_map_ref':
/root/source/glibc-2.7/nscd/nscd_helper.c:404: undefined reference to `__sync_val_compare_and_swap_4'
/root/source/glibc-build/libc_pic.os: In function `*__GI___libc_freeres':
/root/source/glibc-2.7/malloc/set-freeres.c:39: undefined reference to `__sync_bool_compare_and_swap_4'
collect2: ld returned 1 exit status
make[1]: *** Error 1
make: *** Error 2
-----------------------------------------------------
/root/source/glibc-build/libc_pic.os: In function `__nscd_get_map_ref':
/root/source/glibc-2.7/nscd/nscd_helper.c:404: undefined reference to `__sync_val_compare_and_swap_4'
/root/source/glibc-build/libc_pic.os: In function `*__GI___libc_freeres':
/root/source/glibc-2.7/malloc/set-freeres.c:39: undefined reference to `__sync_bool_compare_and_swap_4'
collect2: ld returned 1 exit status
make[1]: *** Error 1
make: *** Error 2
-----------------------------------------------------
查看系統cpu型號:
# uname -a
Linux localhost.localdomain 2.6.18-238.el5 #1 SMP Sun Dec 19 14:24:47 EST 2010 i686 i686 i386 GNU/Linux
Linux localhost.localdomain 2.6.18-238.el5 #1 SMP Sun Dec 19 14:24:47 EST 2010 i686 i686 i386 GNU/Linux
該系統cpu為i686
指明系統cpu型號的方法如下:在/home/glibc-2.9-build/目錄下創建configparms文件。
# echo "CFLAGS += -march=i686" > configparms
然后make即可
# make
5、make check過程,直接make check即可
# make check
6、make dvi過程,安裝GNU C Library Reference Manual,若不安裝則可以省去此步。
在線文檔網址為 http://www.kernel.org/doc/man-pages/
在線文檔網址為 http://www.kernel.org/doc/man-pages/
7、make install過程,即安裝glibc
# make install
# /lib/libc.so.6
GNU C Library stable release version 2.9, by Roland McGrath et al.
# /lib/libc.so.6
GNU C Library stable release version 2.9, by Roland McGrath et al.
參考http://blog.sina.com.cn/s/blog_a5cf7b9a010110ic.html