使用源码升级至glibc-2.7

用的redhat版本太老,而安装mentohust,需要glibc-2.7版本以上,所以从GNU的官网 上下载了glibc-2.7的源码,将原有的glibc-2.5升级到2.7。必须注意的是,几乎所有的应用程序都依赖于glibc的动态库,重新编译安装glibc必须非常谨慎,一旦出错可能导致系统无法继续使用。所以强烈建议阅读源码目录下的INSTALL和FAQ文档。

1 ../glibc-2.7/configure

第一步是配置glibc,出于安全的考虑,glibc不允许在源码目录树下编译,必须新建一个目录,然后在新建目录下运行configure,我就在源码目录的父目录下建了一个glibc-build目录,这样一旦出错就将整个目录移除即可。

 

congfiure最常用的选项是--prefix,--prefix指定了glibc安装的位置,默认是安装到/usr/lcoal,glibc会强烈建议不要安装到这个目录下,通常的做法是--prefix=/usr,这会将glibc安装为linux系统的标准库。

*** On GNU/Linux systems the GNU C Library should not be installed into
*** /usr/local since this might make your system totally unusable.
*** We strongly advise to use a different prefix.  For details read the FAQ.
*** If you really mean to do this, run configure again using the extra
*** parameter `--disable-sanity-checks'.

 

2 make

第二步是编译glibc,make会打印很多信息,而那些包含“***”的信息意味着非常严重的错误。glibc的编译相当耗时,可以给make加上-j选项并行编译glibc。我在make的时候遇到了以下问题。

make 写道
/root/source/glibc-build/libc_pic.os: In function `__libc_fork':
/root/source/glibc-2.7/posix/../nptl/sysdeps/unix/sysv/linux/i386/../fork.c:76: undefined reference to `__sync_bool_compare_and_swap_4'
/root/source/glibc-build/libc_pic.os: In function `__nscd_drop_map_ref':
/root/source/glibc-2.7/nscd/nscd-client.h:320: undefined reference to `__sync_fetch_and_add_4'
/root/source/glibc-build/libc_pic.os: In function `nscd_getpw_r':
/root/source/glibc-2.7/nscd/nscd_getpw_r.c:232: undefined reference to `__sync_fetch_and_add_4'
/root/source/glibc-build/libc_pic.os: In function `__nscd_drop_map_ref':
/root/source/glibc-2.7/nscd/nscd-client.h:320: undefined reference to `__sync_fetch_and_add_4'
/root/source/glibc-build/libc_pic.os: In function `nscd_getgr_r':
/root/source/glibc-2.7/nscd/nscd_getgr_r.c:321: undefined reference to `__sync_fetch_and_add_4'
/root/source/glibc-build/libc_pic.os: In function `__nscd_drop_map_ref':
/root/source/glibc-2.7/nscd/nscd-client.h:320: undefined reference to `__sync_fetch_and_add_4'
/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]: *** [/root/source/glibc-build/libc.so] Error 1
make[1]: Leaving directory `/root/source/glibc-2.7'
make: *** [all] Error 2
 

碰到这个问题需要为为CFLAGS添加march选项。

echo "CFLAGS += -march=i486" > configparms

执行make命令时会将configparms里的内容按照MakeFile的规则进行解析。

3 make check

在安装之前,先用make check检查是否存在错误,一定不要使用存在错误的库。这个check的过程实在太长,出现错误非常郁闷。我在check的时候遇到的问题是:

Timed out: the child process got signal Unknown signal 88

这个问题一直不知如何解决,多运行几次check之后错误又不见了。

4 make install

如果和我一样是从glibc-2.5升级到2.7,需要新建一个/usr/include目录,其中只能包含linux的头文件。

……install遇到各种问题,最后机器直接不能使用,神啊!

glibc太旧,不如换个新操作系统吧,亲!

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值