Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1526121
  • 博文数量: 290
  • 博客积分: 3468
  • 博客等级: 中校
  • 技术积分: 3461
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-28 22:21
文章分类

全部博文(290)

文章存档

2016年(13)

2015年(3)

2014年(42)

2013年(67)

2012年(90)

2011年(75)

分类: LINUX

2011-01-19 20:00:27

Glibc2.8编译

软件包:Glibc2.8.tar.bz2

(下载地址:

系统环境:Ubuntu10.04 + linux-gcc-4.4.3


$tar xf Glibc2.8.tar.bz2

$mkdir build_glibc

$cd build_glibc

$../glibc2.8/configure —prefix=/home/loongson/mylib/


备注:configure之前需要向上面那样的步骤那样另外建立一个新目录作为编译的目录,不然可能会看到类似的提示:
$ ./configure 
configure: error: you must configure in a separate build directory

出错信息:

checking build system type... i686-pc-linux-gnu

checking host system type... i686-pc-linux-gnu

configure: running configure fragment for add-on nptl

checking sysdep dirs... sysdeps/i386/elf nptl/sysdeps/unix/sysv/linux/i386/i686 nptl/sysdeps/unix/sysv/linux/i386 sysdeps/unix/sysv/linux/i386 nptl/sysdeps/unix/sysv/linux nptl/sysdeps/pthread sysdeps/pthread sysdeps/unix/sysv/linux sysdeps/gnu sysdeps/unix/common sysdeps/unix/mman sysdeps/unix/inet sysdeps/unix/sysv/i386 nptl/sysdeps/unix/sysv sysdeps/unix/sysv sysdeps/unix/i386 nptl/sysdeps/unix sysdeps/unix sysdeps/posix sysdeps/i386/i686/fpu nptl/sysdeps/i386/i686 sysdeps/i386/i686 sysdeps/i386/i486 nptl/sysdeps/i386/i486 sysdeps/i386/fpu nptl/sysdeps/i386 sysdeps/i386 sysdeps/wordsize-32 sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/ieee754 sysdeps/generic/elf sysdeps/generic

checking for a BSD-compatible install... /usr/bin/install -c

checking whether ln -s works... yes

checking for gcc... gcc

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ANSI C... none needed

checking how to run the C preprocessor... gcc -E

checking for g++... no

checking for c++... no

checking for gpp... no

checking for aCC... no

checking for CC... no

checking for cxx... no

checking for cc++... no

checking for cl... no

checking for FCC... no

checking for KCC... no

checking for RCC... no

checking for xlC_r... no

checking for xlC... no

checking whether we are using the GNU C++ compiler... no

checking whether g++ accepts -g... no

checking for ranlib... ranlib

checking whether as is GNU as... yes

checking whether ld is GNU ld... yes

checking for as... as

checking version of as... 2.20.1, bad

checking for ld... ld

checking version of ld... 2.20.1, bad

checking for pwd... /bin/pwd

checking for gcc... gcc

checking version of gcc... 4.4.3, ok

checking for gnumake... no

checking for gmake... no

checking for make... make

checking version of make... 3.81, ok

checking for gnumsgfmt... no

checking for gmsgfmt... no

checking for msgfmt... no

checking for makeinfo... no

checking for sed... sed

checking version of sed... 4.2.1, ok

checking for autoconf... no

configure: error:

*** These critical programs are missing or too old: as ld

*** Check the INSTALL file for required versions.


参考解决方法:

$sudo apt-get install g++

$sudo apt-get install autoconf


最后面的那个错误是GCC版本太低或太高了,而我这个太高了

$ld -v

GNU ld (GNU Binutils for Ubuntu) 2.20.1-system.20100303

本来系统就已装有且,版本也不低

修改configure文骗过它


4587 if test -z "$LD"; then //此处$LD是指测试ld

4588 ac_verc_fail=yes

4589 else

4590 # Found it, now check the version.

4591 { echo "$as_me:$LINENO: checking version of $LD" >&5

4592 echo $ECHO_N "checking version of $LD... $ECHO_C" >&6; }

4593 ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]* \.[0-9.]*\).*$/\1/p'`

4594 case $ac_prog_version in

4595 '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;

4596 2.1[3-9]*|2.2[0-9]*)

//红色为后加的部分因为本机的是版本是2.20.1,所以如此修改

4597 ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;

4598 *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;

4599

4600 esac

4601 { echo "$as_me:$LINENO: result: $ac_prog_version" >&5

4602 echo "${ECHO_T}$ac_prog_version" >&6; }

4603 fi

4604 if test $ac_verc_fail = yes; then

4605 LD=: critic_missing="$critic_missing ld"

4606 fi


$ ../glibc-2.8/configure --prefix=/home/loongson/mylib/

出错信息:

configure: error:

*** These critical programs are missing or too old: as

*** Check the INSTALL file for required versions.

参考解决方法:

同上

$ as -v

GNU assembler version 2.20.1 (i486-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.20.1-system.20100303

修改configure

if test -z "$AS"; then //此处$AS是指测试as

4525 ac_verc_fail=yes

4526 else

4527 # Found it, now check the version.

4528 { echo "$as_me:$LINENO: checking version of $AS" >&5

4529 echo $ECHO_N "checking version of $AS... $ECHO_C" >&6; }

4530 ac_prog_version=`$AS --version 2>&1 | sed -n 's/^.*GNU assembler.* \([0- 9]*\.[0-9.]*\).*$/\1/p'`

4531 case $ac_prog_version in

4532 '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;

4533 2.1[3-9]*|2.2[0-9]*)

//红色为后加的部分因为本机的是版本是2.20.1,所以如此修改

4534 ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;

4535 *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;

4536

4537 esac

4538 { echo "$as_me:$LINENO: result: $ac_prog_version" >&5

4539 echo "${ECHO_T}$ac_prog_version" >&6; }

4540 fi

通过上面的发现$LD是指测试ld,此处$AS是指测试as,相应的$CC是指测试gcc


$ ../glibc-2.8/configure --prefix=/home/loongson/mylib/

$ make

出错信息
mawk: scripts/gen-sorted.awk: line 19: syntax error at or near ]
mawk: scripts/gen-sorted.awk: line 19: runaway regular expression /, "", subd ...
make[1]:

*** No rule to make target `/home/wstone/Build/glibc/glibc-build/Versions.all', needed by `/home/wstone/Build/glibc/glibc-build/abi-versions.h'.  Stop.
make[1]: Leaving directory `/home/wstone/Build/glibc/glibc-2.9'
make: *** [all] Error 2

参考解决方法:
这是因为ubuntu使用的是mawk,安装上glibc需要的gawk即可:
$ sudo apt-get install gawk

出错信息:

In file included from ../sysdeps/unix/sysv/linux/syslog.c:10:

../misc/syslog.c: In function ‘__vsyslog_chk’:

../misc/syslog.c:123: sorry, unimplemented: inlining failed in call to ‘syslog’: function body not available

../misc/syslog.c:155: sorry, unimplemented: called from here

make[2]: *** [/home/loongson/software/glibc_build/misc/syslog.o] 错误 1

make[2]:正在离开目录 `/home/loongson/software/glibc-2.8/misc'

make[1]: *** [misc/subdir_lib] 错误 2

make[1]:正在离开目录 `/home/loongson/software/glibc-2.8'

make: *** [all] 错误 2

参考解决方法:

$  echo "CFLAGS +=-O2 -U_FORTIFY_SOURCE  -march=i486 -mtune=native -fno-stack-protector" >configparms

//注意这里的-march=i686uname -a查看)填错则不起效果(eg:若写成i486则出一样的错误)还有这个命令最好是手输,不然没效果,可能是因为word字体格式影响的(因为我从这里复制上去用不了,从网页上复制过来可以用)

$ ../glibc-2.8/configure --prefix=/home/loongson/mylib --disable-profile —enable-kernel=2.6.32.27 && make

出错信息:

/home/loongson/software/glibc_build/elf/librtld.os -Wl,--version-script=/home/loongson/software/glibc_build/ld.map \

-Wl,-soname=ld-linux.so.2 -T /home/loongson/software/glibc_build/elf/ld.so.lds

/home/loongson/software/glibc_build/elf/librtld.os: In function `_dl_start_final':

/home/loongson/software/glibc-2.8/elf/rtld.c:294: undefined reference to `_begin'

/usr/bin/ld: /home/loongson/software/glibc_build/elf/librtld.os: relocation R_386_GOTOFF against undefined hidden symbol `_begin' can not be used when making a shared object

/usr/bin/ld: final link failed: Bad value

collect2: ld returned 1 exit status

make[2]: *** [/home/loongson/software/glibc_build/elf/ld.so] 错误 1

make[2]:正在离开目录 `/home/loongson/software/glibc-2.8/elf'

make[1]: *** [elf/subdir_lib] 错误 2

make[1]:正在离开目录 `/home/loongson/software/glibc-2.8'

make: *** [all] 错误 2

参考解决方法:

修改 glibc-2.8/elf/Makefile (302)

$(LDFLAGS-rtld) -Wl,-z,defs -Wl,–verbose 2>&1 |\
LC_ALL=C \
sed -e ‘/^=========/,/^=========/!d;/^=========/d’\
-e ’s/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/’ \     #
302
-e ’s/\. = .* + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/’ \    #
修改之后
> $@.lds
$(LINK.o) -nostdlib -nostartfiles -shared -o $@\
$(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now))\


把蓝色的部分修改成红色的那样

$make

$make install













Glibc2.11.2 编译

其它步骤同上

$../glibc2.11.2/configure —prefix=/home/loongson/mylib/

$make

出错信息:

../misc/syslog.c: In function ‘__vsyslog_chk’:

../misc/syslog.c:123: sorry, unimplemented: inlining failed in call to ‘syslog’: function body not available

../misc/syslog.c:155: sorry, unimplemented: called from here

make[2]: *** [/home/loongson/software/build/misc/syslog.o] 错误 1

make[2]:正在离开目录 `/home/loongson/software/glibc-2.11.2/misc'

make[1]: *** [misc/subdir_lib] 错误 2

make[1]:正在离开目录 `/home/loongson/software/glibc-2.11.2'

make: *** [all] 错误 2

on/software/build/elf/ld.so -lgcc

/home/loongson/software/build/libc_pic.os: In function `iconv_open':

/home/loongson/software/glibc-2.11.2/iconv/iconv_open.c:89: undefined reference to `__stack_chk_fail_local'

/home/loongson/software/build/libc_pic.os: In function `__gconv_open':

/home/loongson/software/glibc-2.11.2/iconv/gconv_open.c:344: undefined reference to `__stack_chk_fail_local'

/home/loongson/software/build/libc_pic.os: In function `find_derivation':

/home/loongson/software/glibc-2.11.2/iconv/gconv_db.c:677: undefined reference to `__stack_chk_fail_local'

/home/loongson/software/build/libc_pic.os: In function `add_module':

/home/loongson/software/glibc-2.11.2/iconv/gconv_conf.c:358: undefined reference to `__stack_chk_fail_local'

/home/loongson/software/build/libc_pic.os: In function `__gconv_get_path':

/home/loongson/software/glibc-2.11.2/iconv/gconv_conf.c:536: undefined reference to `__stack_chk_fail_local'

/home/loongson/software/build/libc_pic.os:/home/loongson/software/glibc-2.11.2/iconv/gconv_conf.c:610: more undefined references to `__stack_chk_fail_local' follow

/usr/bin/ld: /home/loongson/software/build/libc.so: hidden symbol `__stack_chk_fail_local' isn't defined

/usr/bin/ld: final link failed: Nonrepresentable section on output

collect2: ld returned 1 exit status

make[1]: *** [/home/loongson/software/build/libc.so] 错误 1

make[1]:正在离开目录 `/home/loongson/software/glibc-2.11.2'

make: *** [all] 错误 2

参考解决方法:

$ echo "CFLAGS +=-O2 -U_FORTIFY_SOURCE  -march=i686 -mtune=native -fno-stack-protector" >configparms

//注意这里的-march=i686uname -a查看)填错则不起效果(eg:若写成i486则出一样的错误)

$ ../glibc-2.11.2/configure --prefix=/home/loongson/mylib --disable-profile --enable-kernel=2.6.32.27 && make

$ make install

出错信息:

/home/loongson/software/build/elf/ldconfig: Can't open configuration file /home/loongson/mylib/etc/ld.so.conf: No such file or directory

make[1]: Leaving directory `/home/loongson/software/glibc-2.11.2'

参考解决方法:

$ touch /home/loongson/mylib/etc/ld.so.conf

$ make install




参考文档:




2011-1-19

阅读(12127) | 评论(0) | 转发(3) |
0

上一篇:Gtk+-2.20.1编译

下一篇:Udev编译基于龙芯

给主人留下些什么吧!~~