主机升级到Fedora 14,下载了crosstool-ng-1.10.0,编译目标为 arm-cortex_a8
编译步骤:
1、直接拷贝 crosstool-ng-1.10.0/samples/arm-cortex_a8-linux-gnueabi/crosstool.config 到目标目录中的 .config
2、执行 ct-ng menuconfig 查看和校验编译选项,不做任何改动。
3、执行 ct-ng build,如果想加快编译速度,并且主机具备多核,则可以使用选项build.X来编译,其中X表示使用的线程数,一般最多为主机核心的2倍就足够。
编译并未如期通过,出现如下错误:
[INFO ] ================================================================= [INFO ] Installing static core C compiler [EXTRA] Configuring static core C compiler [EXTRA] Building static core C compiler [ERROR] make[2]: *** [cc1-dummy] Error 1 [ERROR] make[1]: *** [all-gcc] Error 2 [ERROR] Build failed in step 'Installing static core C compiler' [ERROR] Error happened in '/home/sam/devel/devkit8000/crosstool-ng/crosstool-ng-1.10.0/scripts/functions' in function 'CT_DoExecLog' (line unknown, sorry) [ERROR] called from '/home/sam/devel/devkit8000/crosstool-ng/crosstool-ng-1.10.0/scripts/build/cc/gcc.sh' at line # 320 in function 'do_cc_core' [ERROR] called from '/home/sam/devel/devkit8000/crosstool-ng/crosstool-ng-1.10.0/scripts/build/cc/gcc.sh' at line # 52 in function 'do_cc_core_pass_1' [ERROR] called from '/home/sam/devel/devkit8000/crosstool-ng/crosstool-ng-1.10.0/scripts/crosstool-NG.sh' at line # 606 in function 'main' [ERROR] Look at '/home/sam/x-tools/arm-cortex_a8-linux-gnueabi/build.log' for more info on this error. [ERROR] (elapsed: 10:11.57) [10:11] / make: *** [build] 错误 2
错误是在第一次编译静态GCC时出错的,按照出错提示查看编译日志build.log,找到如下错误信息:[ALL ] /usr/bin/ld: cannot find -lstdc++ [ALL ] collect2: ld returned 1 exit status [ERROR] make[2]: *** [cc1-dummy] Error 1
看来是链接程序找不到 libstdc++ 所致,启动ct-ng menuconfig, 进入菜单 C Compiler,可以看到
[*] Link libstdc++ statically into the gcc binary
选项,GCC在编译时被静态链接了,也就是没有生成libstdc++.so,所以导致libstdc++连接不到,因此去掉该选项,再次编译。
出现如下错误:
[INFO ] Installing C library headers [EXTRA] Configuring C library [EXTRA] Installing C library headers [ERROR] make[3]: *** [manual/install-headers] Error 2 [ERROR] make[2]: *** [install-headers] Error 2 [ERROR] Build failed in step 'Installing C library headers' [ERROR] Error happened in '/home/sam/devel/devkit8000/crosstool-ng/crosstool-ng-1.9.3/scripts/functions' in function 'CT_DoExecLog' (line unknown, sorry) [ERROR] called from '/home/sam/devel/devkit8000/crosstool-ng/crosstool-ng-1.9.3/scripts/build/libc/glibc.sh' at line # 175 in function 'do_libc_headers' [ERROR] called from '/home/sam/devel/devkit8000/crosstool-ng/crosstool-ng-1.9.3/scripts/crosstool-NG.sh' at line # 597 in function 'main' [ERROR] Look at '/home/sam/x-tools/arm-cortex_a8-linux-gnueabi/build.log' for more info on this error. [ERROR] (elapsed: 38:55.31) [38:56] / make[1]: *** [build] 错误 2 make: *** [build.4] 错误 2
可见错误的是在编译GLIBC时发生的,打开build.log,可以看到如下错误信息: