CentOS-5.5下编译安装glibc

来源:互联网 发布:spring实战第四版源码 编辑:程序博客网 时间:2024/05/01 01:14
 

----------一些说明
1、最好用root

2、glibc版本:glibc-2.7
3、'make'过程中,出现'***'说明是很严重的错误。INSTALL文件摘录如下:
To build the library and related programs, type `make'.  This will
produce a lot of output, some of which may look like errors from `make'
but isn't.  Look for error messages from `make' containing `***'.
Those indicate that something is seriously wrong.

 

----------configure
[/test]# mkdir glibc-build
[/test]# cd glibc-build
[/test/glibc-build]# ../glibc-2.7/configure --prefix=/usr
得到文件:bits  config.h  config.log  config.make  config.status  Makefile

【常见错误】
1、[/test/glibc-2.7]# ./configure
不能在当前目录下configure

INSTALL文件摘录如下:
GNU libc cannot be compiled in the source directory.  You must build it
in a separate build directory.  For example, if you have unpacked the
glibc sources in `/src/gnu/glibc-2.4', create a directory
`/src/gnu/glibc-build' to put the object files in.  This allows
removing the whole build directory in case an error occurs, which is
the safest way to get a fresh start and should always be done.


2、[/test/glibc-build]# ../glibc-2.7/configure(未加'--prefix=/usr')
错误信息如下:
*** 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'.

只得到文件:config.log

INSTALL文件摘录如下:
`configure' takes many options, but the only one that is usually
mandatory is `--prefix'.  This option tells `configure' where you want
glibc installed.  This defaults to `/usr/local', but the normal setting
to install as the standard system library is `--prefix=/usr' for
GNU/Linux systems and `--prefix=' (an empty prefix) for GNU/Hurd
systems.

-----关于安装目录的选择

--prefix=PREFIX
安装目录,默认为 /usr/local
Linux文件系统标准要求基本库必须位于 /lib 目录并且必须与根目录在同一个分区上,但是 /usr 可以在其他分区甚至是其他磁盘上。因此,如果指定 --prefix=/usr ,那么基本库部分将自动安装到 /lib 目录下,而非基本库部分则会自动安装到 /usr/lib 目录中。但是如果保持默认值或指定其他目录,那么所有组件都间被安装到PREFIX目录下。


----------make
1、
[/test/glibc-build]# vim config.make

2、
在<CFLAGS = -g -O2 >后加<-march=i686>
(CFLAGS = -g -O2 -march=i686,根据'uname -m'得知是'i686',不知道此处能不能直接用`uname -m`代替)
【推荐】http://www.linuxsir.org/bbs/thread368805.html


【常见错误】
1、'make'后报错:
make[1]: *** [/test/glibc-build/libc.so] 错误 1
make[1]: Leaving directory `/test/glibc-2.7'
make: *** [all] 错误 2
解决:见上面(在<CFLAGS = -g -O2 >后加<-march=i686>)

 

----------make install
[/test/glibc-build]# make install

 

----------glibc版本查看
共有三种方法:
1、[...]# /lib/libc.so.6
任意目录执行此命令行

2、通过C程序

#include <stdio.h>#include <gnu/libc-version.h>int main (void){puts(gnu_get_libc_version());return 0;}


上述两种方法,FAQ文件摘要如下:
4.9. How can I find out which version of glibc I am using in the moment?

{UD} If you want to find out about the version from the command line simply
run the libc binary.  This is probably not possible on all platforms but
where it is simply locate the libc DSO and start it as an application.  On
Linux like

 /lib/libc.so.6

This will produce all the information you need.

What always will work is to use the API glibc provides.  Compile and run the
following little program to get the version information:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <stdio.h>
#include <gnu/libc-version.h>
int main (void) { puts (gnu_get_libc_version ()); return 0; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This intece can also obviously be used to perform tests at runtime if
this should be necessary.


3、
[...]# ldd --version

原创粉丝点击