linux安装最新版的glib库,GLib库安装与简析

GLib是GTK+和GNOME工程的基础底层库,本文详细介绍了在CentOS上安装最新版GLib的过程,包括检查当前版本、下载源码包、编译和解决安装过程中遇到的各种错误。GLib提供数据结构、宏和运行时功能,适用于多种操作系统平台。文章还简要分析了GLib与GCC的关系及其在系统中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值