Ubuntu 12.04
gcc4.6.3
查看当前所用glibc版本
ldd --version
ldd (Ubuntu EGLIBC 2.15-0ubuntu10.3) 2.15
Copyright (C) 2012 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.
Written by Roland McGrath and Ulrich Drepper.
下载glibc2.15源码 http://ftp.gnu.org/gnu/glibc
解压后目录下执行 ./configure --prefix=/usr/local/glib --enable-static --disable-shared CFLAGS=\"-static\"
编译出错
configure: error: you must configure in a separate build directory
跳出新建目录 glibc-2.15-build 在该目录下以绝对路径执行
出错
configure: error:
*** LD_LIBRARY_PATH shouldn\'t contain the current directory when
*** building glibc. Please change the environment variable
*** and run configure again.
暂时删除 LD_LIBRARY_PATH 之后再添加
linux@ubuntu:~/songhui/software/glibc-2.15-bulid$ echo $LD_LIBRARY_PATH
:/home/linux/dynamiclib/libsum.so
linux@ubuntu:~/songhui/software/glibc-2.15-bulid$ LD_LIBRARY_PATH=
之后 执行
vim /etc/profile export LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/home/linux/dynamiclib/libsum.so //wq 保存退出,使之生效 source /etc/profile
出错
configure: error: er with -z relro support required
安装
sudo apt-get install gawk
出错
/home/linux/songhui/software/glibc-2.15-bulid/config.h:3:3: error: #error \"glibc cannot be compiled without optimization\"
重新configure 在CFLAGS中添加 CFLAGS=\"-static -g -O2 -march=i686\"
出错
../sysdeps/i386/i686/multiarch/strchr.S: Assembler messages:
../sysdeps/i386/i686/multiarch/strchr.S:25: Error: junk at end of line, first unrecognized character is `1\'
../sysdeps/i386/i686/multiarch/strchr.S:26: Error: junk at end of line, first unrecognized character is `1\'
../sysdeps/i386/i686/multiarch/strchr.S:27: Error: Missing symbol name in directive
../sysdeps/i386/i686/multiarch/strchr.S:27: Error: junk at end of line, first unrecognized character is `1\'
../sysdeps/i386/i686/multiarch/strchr.S:29: Error: Missing symbol name in directive
../sysdeps/i386/i686/multiarch/strchr.S:29: Error: junk at end of line, first unrecognized character is `.\'
../sysdeps/i386/i686/multiarch/strchr.S:30: Error: junk at end of line, first unrecognized character is `1\'
../sysdeps/i386/i686/multiarch/strchr.S:40: Error: junk `.get_pc_thunk.bx\' after
Google了一下,大概是gcc3.4.2及以前的版本对奔腾3及以后的CPU定义了#define __i686 1,但之后的gcc使用__x86并修复了(我的是4.6.3)(而且TMD 2.16的glibc也对应修复了,我需要的是2.15)
修改对应文件中的__i686 -> __x86
无效
找到外国友人一段话
The problem is caused by your GCC defining __i686. You can confirm that in fact it does that with this command:
gcc -dD -E -xc /dev/null | grep __i686
If this command produces output, then that\'s the problem. To fix it, use:
configure --prefix=/usr CC=\'gcc -U__i686\'
or build a newer version of glibc.
修改
/home/linux/songhui/software/glibc-2.15/configure --prefix=/usr/local/glib --enable-static --disable-shared CFLAGS=\"-static -g -O2 -march=i686\"
为
/home/linux/songhui/software/glibc-2.15/configure --prefix=/usr/local/glib CC=“gcc -U__i686” --enable-static --disable-shared CFLAGS=\"-static -g -O2 -march=i686\"
重新编译
出错
In file included from ../sysdeps/unix/sysv/linux/syslog.c:10:0:
../misc/syslog.c: In function ‘__vsyslog_chk’:
../misc/syslog.c:123:1: sorry, unimplemented: inlining failed in call to ‘syslog’: function body not available
../misc/syslog.c:155:9: sorry, unimplemented: called from here
make[2]: *** [/home/linux/songhui/software/glibc-2.15-bulid/misc/syslog.o] Error 1
The -U_FORTIFY_SOURCE is required to avoid failure of gcc ../sysdeps/unix/sysv/linux/syslog.c (In function ‘__vsyslog_chk’: [...] inlining failed in call to ‘syslog’)
The -fno-stack-protector is required to avoid failure of gcc [...] elf/dl-allobjs.os libc_pic.a((init-first.os):(.data+0x0): multiple definition of \'__libc_multiple_libcs\').
修改为
/home/linux/songhui/software/glibc-2.15/configure --prefix=/usr/local/glib CC=\"gcc -U__i686\" --enable-static --disable-shared CFLAGS=\"-static -g -O2 -U_FORTIFY_SOURCE -fno-stack-protector -march=i686\"
出错
No rule to make target `/Archive/crosstool-0.38/build/
i686-unknown-linux-gnu/gcc-4.0.2-glibc-2.3.5/build-glibc/misc/
vm86.o\', needed by `/Archive/crosstool-0.38/build/i686-unknown-linux-
gnu/gcc-4.0.2-glibc-2.3.5/build-glibc/misc/stamp.o\'. Stop.
make[1]: *** [misc/subdir_lib] Error 2
make: *** [lib] Error 2
(错误没有截取,但是出错的地方一样)
修改 去掉 --disable-shared
/home/linux/songhui/software/glibc-2.15/configure --prefix=/usr/local/glib CC=\"gcc -U__i686\" --enable-static CFLAGS=\"-static -g -O2 -U_FORTIFY_SOURCE -fno-stack-protector -march=i686\"
make OK,
sudo make install OK
(每次出错后,基本都是全部删除重来configure)
编译后文档及源码:
继续阅读与本文标签相同的文章
这次,罗永浩一句人工智能也没提
线框图知多少?
-
Pdf转excel的简单方法分享
2026-05-18栏目: 教程
-
人脸识别技术发展如花如荼 未来可期
2026-05-18栏目: 教程
-
MaxCompute开发者夏季颁奖礼~久久感谢有你
2026-05-18栏目: 教程
-
第六届世界互联网大会即将举行 乌镇将试行5G自动微公交
2026-05-18栏目: 教程
-
2019全球智能化商业峰会秋季场下周三开幕
2026-05-18栏目: 教程
