安装glibc库

来源:互联网 发布:小霸王网络机顶盒 编辑:程序博客网 时间:2024/05/19 05:30
Linux下C开发环境的搭建过程(三) (2010-12-15 21:36:07)转载
标签: linux 开发环境 c语言 glibc gcc 安装 杂谈 分类: 学无止境
Linux下C开发环境的搭建过程(三)
——安装glibc

有些软件可能要求系统的 Glibc 高于某个版本才可以正常运行,如果您的 Glibc 低于要求的版本,为了运行这些软件,您就不得不升级您的 Glibc了。比如:
qq: error while loading shared libraries: requires glibc 2.5 or later dynamic linker

您可以寻找已经编译好的rpm包或者使用源代码的方式升级Glibc。

RPM包方式安装glibc
RPM虽然比较容易安装,但就是依赖问题不好解决。给出一个下载地址:
http://mirrors.jtlnet.com/centos/5.5/os/i386/CentOS/
$ rpm –ivh glibc-2.5-49.i386.rpm

不过我用的是CentOS 4.8,貌似不能兼容……
error: Failed dependencies:
glibc-common = 2.5-49 is needed by glibc-2.5-49.i386
glibc > 2.3.4 conflicts with glibc-common-2.3.4-2.43.el4_8.3.i386

安装完成后,可以查看是否已升级:
$ ls -l /lib/libc.so.6
lrwxrwxrwx 1 root root 11 10-08 22:08 /lib/libc.so.6 -> libc-2.5.so

编译安装glibc
下载glibc
[root@localhost test]# pwd
/test
[root@localhost test]# wget http://ftp.gnu.org/gnu/glibc/glibc-2.9.tar.bz2

下载glibc-linuxthreads
[root@localhost test]# wget http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.5.tar.bz2

解压
[root@localhost test]# tar -jvxf glibc-2.9.tar.bz2
[root@localhost test]# cd glibc-2.9
[root@localhost glibc-2.9]# tar -jvxf ../glibc-linuxthreads-2.5.tar.bz2

配置
[root@localhost glibc-2.9]# cd ..
[root@localhost test]# export CFLAGS="-g -O2 -march=i486"
[root@localhost test]# mkdir glibc-build
[root@localhost test]# cd glibc-build
[root@localhost glibc-build]# ../glibc-2.9/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

安装
[root@localhost glibc-build]# make
[root@localhost glibc-build]# make install

安装编译过程中需要注意三点:
1、要将glibc-linuxthreads解压到glibc目录下。
2、不能在glibc当前目录下运行configure。
3、否则如果出现错误:error "glibc cannot be compiled without optimization",需要加上优化开关:[root@localhost test]# export CFLAGS="-g -O2 -march=i486"
原创粉丝点击