glibc、libc和glib详解 ldd命令查看依赖
- 2015-06-24 21:35:00
- admin
- 原创 8848
一、什么是glibc、libc和glib
glibc是linux的GUN C函数库,是linux系统中最底层的API,几乎其它任何运行时库都依赖于glibc。glibc除了封装linux操作系统所提供的系统服务,它本身也提供了许多其它必要功能服务的实现,例如:动态加载模块libdl、实时扩展接口librt。glibc安装:
yum install glibc安装动态版本库,yum install glibc-static安装静态版本库。
libc是Linux下的ANSI C函数库,被glibc包含,一般只包括以下功能:
<ctype.h> <errno.h> <float.h> <math.h> <stddef.h> <stdio.h> <stdlib.h>
<string.h> <time.h> <stdarg.h> <signal.h> <setjmp.h> <locale.h> <assert.h>
libc位于/usr/lib64/libc.so、/usr/lib64/libc.a。
glib是Linux下C的一些工具库,和glibc没有关系。
查看glibc版本:
[root@ebs-19233 ~]# /lib64/libc.so.6
GNU C Library stable release version 2.12, by Roland McGrath et al.
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-11).
Compiled on a Linux 2.6.32 system on 2015-05-27.
Available extensions:
The C stubs add-on version 2.1.2.
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
RT using linux kernel aio
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
[root@ebs-19233 ~]# strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_PRIVATE
[root@ebs-19233 ~]# ldd --version
ldd (GNU libc) 2.12
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ldd查看动态库或可执行文件的依赖动库,可以用于解决动态库缺失问题:
[root@ebs-19233 ~]# ldd /bin/sh
linux-vdso.so.1 => (0x00007fffc7361000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003207c00000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fcdec97b000)
libc.so.6 => /lib64/libc.so.6 (0x00007fcdec5e6000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcdecb89000)