需要运行一个DEMO,因为glibc版本过低,无法运行,所以需要升级glibc,错误提示如下:
$ ./nsm
./nsm: /lib/i386-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by ./nsm)
查看系统的glibc版本:
$ ll /lib/i386-linux-gnu/libc.so.6
lrwxrwxrwx 1 root root 12 2012-11-16 05:21 /lib/i386-linux-gnu/libc.so.6 -> libc-2.13.so*
着手升级,正常步骤如下:
1、下载 glibc-2.14.tar.gz;
2、
[root@localhost ~]
# tar xvf glibc-2.14.tar.gz
[root@localhost ~]
# cd glibc-2.14
[root@localhost glibc-2.14]
# mkdir build
[root@localhost glibc-2.14]
# cd ./build
[root@localhost build]
# ../configure --prefix=/opt/glibc-2.14
[root@localhost build]
# make -j4
[root@localhost build]
# make install
注意要新创建那个build目录,不能在主目录下直接安装!
安装过程中遇到如下问题:
1、
root@ubuntu:/home/cq/下载/glibc-2.14/build# make && make instal
make -r PARALLELMFLAGS="" CVSOPTS="" -C .. objdir=`pwd` all这是因为ubuntu使用的是mawk,安装上glibc需要的gawk即可:
$ sudo apt-get install gawk
2、
-build/math/s_isnanf.os
../sysdeps/i386/fpu/s_frexp.S: Assembler messages:
../sysdeps/i386/fpu/s_frexp.S:66: Error: invalid identifier for ".ifdef"
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: Missing symbol name in directive
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: Missing symbol name in directive
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `.'
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
../sysdeps/i386/fpu/s_frexp.S:66: Error: expected comma after name `' in .size directive
../sysdeps/i386/fpu/s_frexp.S:66: Error: ".endif" without ".if"
../sysdeps/i386/fpu/s_frexp.S:66: Error: junk `.get_pc_thunk.dx' after expression
make[2]: *** [/home/cq/下载/glibc-build/math/s_frexp.os] 错误 1
make[2]: *** 正在等待未完成的任务....
make[2]:正在离开目录 `/home/cq/下载/glibc-2.14/math'
make[1]: *** [math/subdir_lib] 错误 2
make[1]:正在离开目录 `/home/cq/下载/glibc-2.14'
make: *** [all] 错误 2
解决方法是:
1)、在glibc源码目录下找到文件:nptl/sysdeps/pthread/pt-initfini.c,找到第46行附近:asm("\n#include \"defs.h\"");在其后添加代码:
asm ("\n#if defined __i686 &&defined __ASSEMBLER__");
asm ("\n#undef __i686");
asm ("\n#define __i686 __i686");
asm ("\n#endif");
2)、在glibc源码目录下找到文件:sysdeps/unix/sysv/linux/i386/sysdep.h,找到第30行附近:#include
#if defined __i686 && defined__ASSEMBLER__
#undef __i686
#define __i686 __i686
#endif
重新make
3、
-o /home/cq/下载/glibc-build/misc/err.o -MD -MP -MF /home/cq/下载/glibc-build/misc/err.o.dt -MT /home/cq/下载/glibc-build/misc/err.o
../misc/syslog.c:123:1: 对不起,尚未实现: 调用‘syslog’时内联失败:函数体不可用
../misc/syslog.c:155:9: 对不起,尚未实现: 从此处调用
make[2]: *** [/home/cq/下载/glibc-build/misc/syslog.o] 错误 1
make[2]: *** 正在等待未完成的任务....
make[2]:正在离开目录 `/home/cq/下载/glibc-2.14/misc',
make[1]: *** [misc/subdir_lib] 错误 2
make[1]:正在离开目录 `/home/cq/下载/glibc-2.14'
加入如下编译选项即可解决
export CFLAGS="-O2 -U_FORTIFY_SOURCE -march=i686 -mtune=native -fno-stack-protector"
4、
/home/cq/下载/glibc-build/elf/ldconfig: Can't open configuration file /home/cq/下载/glibc-build/etc/ld.so.conf: No such file or directory
make[1]: Leaving directory `/home/cq/下载/glibc-2.14'
root@ubuntu:/home/cq/下载/glibc-build#
解决办法:touch /etc/ld.so.conf