Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1031080
  • 博文数量: 123
  • 博客积分: 5051
  • 博客等级: 大校
  • 技术积分: 1356
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-14 10:56
文章分类
文章存档

2012年(1)

2011年(21)

2010年(13)

2009年(55)

2008年(33)

分类: LINUX

2009-08-24 10:00:14

编译LFS过程中遇到的错误以及解决的方法

在编译安装过程中,一定要选好编译环境,如果你要进行LFS6.3以下的,那么不推荐使用高于或者是等于4.2版本的gcc,4.1最好。如果你要进行的LFS6.4,那么不应该使用4.3.0以上的(不包括4.3.0)。
在编译过程中,也许你需要进行多次编译才能编译成功,所以,这个过程刚开始有点难熬,不过很有意思.

1、编译binutils的时候出现错误
当运行下面步骤时:
make -C ld LIB_PATH=/tools/lib

/tools/bin/ld: unrecognized option '--hash-style=both'
/tools/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
make[2]: *** [ld-new] Error 1
make[2]: Leaving directory `/mnt/lfs/sources/binutils-build/ld'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/lfs/sources/binutils-build/ld'
make: *** [all-recursive-am] Error 2
make: Leaving directory `/mnt/lfs/sources/binutils-build/ld'

通过google搜索,在博客http://blog.chinaunix.net/u1/57069/showart_512313.html
上得到了下面的解决方法.

make -C ld LIB_PATH=/tools/lib CC="gcc -B/usr/bin/"
编译成功

另外的,在第一遍安装GCC也遇到一样的问题,只要要把CC="gcc -B/usr/bin/"放在./configure前面
就OK了.

2、glibc-build/csu/version-info.h中会出现“\""的语法错误,只要更正即可.

3、如果在编译glic过程中出现下面的错误
/home/patrick/glibc-build/elf/librtld.os: In function `print_statistics':
/home/patrick/glibc-2.5.1/elf/rtld.c:2830: undefined reference to `__stack_chk_fail_local'
/home/patrick/glibc-build/elf/librtld.os: In function `process_dl_debug':
/home/patrick/glibc-2.5.1/elf/rtld.c:2466: undefined reference to `__stack_chk_fail_local'
/home/patrick/glibc-build/elf/librtld.os: In function `process_envvars':
/home/patrick/glibc-2.5.1/elf/rtld.c:2725: undefined reference to `__stack_chk_fail_local'
/home/patrick/glibc-build/elf/librtld.os: In function `dl_main':
/home/patrick/glibc-2.5.1/elf/rtld.c:2346: undefined reference to `__stack_chk_fail_local'
/home/patrick/glibc-build/elf/librtld.os: In function `print_search_path':
/home/patrick/glibc-2.5.1/elf/dl-load.c:1571: undefined reference to `__stack_chk_fail_local'
/home/patrick/glibc-build/elf/librtld.os:/home/patrick/glibc-2.5.1/elf/dl-load.c:1791: more undefined
那么,这个时候需要重新编译gcc,在gcc的配置文件中将变量CFLAGS添加 -fno-stack-protector,即
关闭堆栈保护,再进行glibc的编译即可解决.

4、如果编译glibc的过程中出现类似下面的错误
/tmp/cclA2UVR.s:55: Error: suffix or operands invalid for `fnstsw'
可以知道,这是因为glibc版本太低的问题,只要打上补丁即可,或者是直接更改源代码,这个需要更改的
文件为/mnt/lfs/sources/glibc-2.*/sysdeps/i386/fpu/ftestexcept.c
之后将int temp改为short temp即可.


在编译glibc的时候出的错误:
../glibc-2.3.6/configure --prefix=/tools \
--disable-profile --enable-add-ons \
--enable-kernel=2.6.0 --with-binutils=/tools/bin \
--without-gd --with-headers=/tools/include \
--without-selinux --build=i686-pc-linux-gnu --host=i686-linux libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes

可以解决long double 值的问题“checking size of long double... configure: error: cannot compute sizeof (long double), 77”
解决configure: error: forced unwind support is required


/xgcc -B./ -B/tools/i686-pc-linux-gnu/bin/ -isystem /tools/i686-pc-linux-gnu/include -isystem /tools/i686-pc-linux-gnu/sys-include -L/mnt/lfs/sources/gcc-build/gcc/../ld -O2 -O2 -g -O2  -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -I. -I. -I../../gcc-4.1.2/gcc -I../../gcc-4.1.2/gcc/. -I../../gcc-4.1.2/gcc/../include -I../../gcc-4.1.2/gcc/../libcpp/include   -g0 -finhibit-size-directive -fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss -fno-unit-at-a-time  -fno-omit-frame-pointer \
  -c ../../gcc-4.1.2/gcc/crtstuff.c -DCRT_BEGIN \
  -o crtbegin.o
In file included from ../../gcc-4.1.2/gcc/crtstuff.c:68:
../../gcc-4.1.2/gcc/tsystem.h:90:19: error: stdio.h: No such file or directory
../../gcc-4.1.2/gcc/tsystem.h:93:23: error: sys/types.h: No such file or directory
../../gcc-4.1.2/gcc/tsystem.h:96:19: error: errno.h: No such file or directory
../../gcc-4.1.2/gcc/tsystem.h:103:20: error: string.h: No such file or directory../../gcc-4.1.2/gcc/tsystem.h:104:20: error: stdlib.h: No such file or directory../../gcc-4.1.2/gcc/tsystem.h:105:20: error: unistd.h: No such file or directoryIn file included from ./include/syslimits.h:7,
                 from ./include/limits.h:11,
                 from ../../gcc-4.1.2/gcc/tsystem.h:108,
                 from ../../gcc-4.1.2/gcc/crtstuff.c:68:
./include/limits.h:122:61: error: limits.h: No such file or directory
In file included from ../../gcc-4.1.2/gcc/crtstuff.c:68:
../../gcc-4.1.2/gcc/tsystem.h:111:18: error: time.h: No such file or directory
make[2]: *** [crtbegin.o] Error 1
make[2]: Leaving directory `/mnt/lfs/sources/gcc-build/gcc'
make[1]: *** [stage1_build] Error 2
make[1]: Leaving directory `/mnt/lfs/sources/gcc-build/gcc'
make: *** [bootstrap] Error 2

这个错误是由于gcc编译安装的时候,补丁没打造成的,只要将第一步中的补丁打上,重新编译安装gcc即可.

(动态更新中)
阅读(2820) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~