GLib是GTK+和GNOME工程的基础底层核心程序库,是一个综合用途的实用的轻量级的C程序库,
它提供C语言的常用的数据结构的定义、相关的处理函数,有趣而实用的宏,
可移植的封装和一些运行时机能,如事件循环、线程、动态调用、对象系统等的API。
它能够在类UNIX的操作系统平台(如LINUX, HP-UNIX等),WINDOWS,OS2和BeOS等操作系统台上运行。
一、GLib在CentOS上的安装
检查系统当前的版本
# rpm -qi glibc
Name : glibc Relocations: (not relocatable)
Version : 2.5 Vendor: Red Hat, Inc.
Release : 49 Build Date: Wed 10 Mar 2010 07:01:43 PM CST
Install Date: Wed 01 Jun 2011 05:50:51 PM CST Build Host: x86-005.build.bos.redhat.com
Group : System Environment/Libraries Source RPM: glibc-2.5-49.src.rpm
Size : 11658546 License: LGPL
Signature : DSA/SHA1, Thu 18 Mar 2010 01:18:05 AM CST, Key ID 5326810137017186
Packager : Red Hat, Inc. < />
Summary : The GNU libc libraries.
Description :
The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.
显示系统的glibc库版本为2.5。
在CentOS中用更新命令到2.5已经是最新版本了,只好手动下载 glibc的源码包编译安装更新。
可以在 看到当前的最新版本,
我看到的最新版本是glibc-2.22。
# cd /usr/src
# mkdir glibc-2.22-build
# wget glibc-2.22.tar.gz
# tar zxvf glibc-2.22.tar.gz
# cd /usr/src/glibc-2.22-build/
# export CFLAGS="-g -O2 -march=i686"
网上有些地方加优化开关 -O2 时(大写字母O),写的是 -02 (数字零),
所以拷贝过来仍然出现3中的错误,所以请注意。
# /usr/src/glibc-2.22-build/glibc-2.22/configure --prefix=/usr/src/glibc-2.22-build/ --with-headers=/usr/include
# make
# make install
注意:
1.在目录usr/src/glibc-2.22执行configure命令时不能执行,需在外部文件夹glibc-2.22-build 执行
2.加上优化开关,export CFLAGS="-g -O2 -march=i686",否则会出现错误,此处的i686请参照自己的机器
出错与解决:
1. 运行configure时报错:
# /usr/src/glibc-2.22-build/glibc-2.22/configure --prefix=/usr/src/glibc-2.22-build/ --with-headers=/usr/include
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for suffix of object files... configure: error: in `/usr/src/glibc-2.22-build/glibc-2.22':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details
解决方案:
是本机的GCC没有安装或配置好,需要重新安装和配置GCC;
2. 运行configure时报错:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checkin