我正在尝试基于启用了gold和链接时优化的GCC4.5和newlib构建交叉编译工具链。GCC编译完好,但没有生成crt1.o或crti.o文件。因此,当我尝试使用编译器构建Newlib时,它会出现以下错误信息:
ld: error: cannot open crti.o: No such file or directory
ld: error: cannot open crtn.o: No such file or directory
ld: error: cannot find -lc
在搜索安装了GCC4.5的目录中名为crt*的文件时,我得到了以下结果:
find ../../../tooltarget/ -name "crt*" -print #(result modified to consume less space)
crtprec80.o, crtend.o, crtfastmath.o, crtbegin.o, crtendS.o, crtprec32.o, crtbeginS.o, crtbeginT.o, crtprec64.o
从GCC规范来看,gcc需要crtbegin.o和crti.o文件,但只有其中一个文件可用。
*startfile:
%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o
%s;:crtbegin.o%s}
以下是我在编译GCC时使用的标志:
--prefix=${TTP}/usr --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=x86_64-awn-linux-gnu
--with-gmp=${TTP}/usr --with-mpc=${TTP}/usr
--with-mpfr=${TTP}/usr --with-libelf=${TTP}/usr
--enable-languages=c --enable-lto
--disable-nls --disable-shared
--disable-multilib --disable-decimal-float
--disable-libmudflap --disable-libssp
--disable-libgomp --disable-threads
--without-headers --with-newlib
--with-build-sysroot=${TTP} --with-build-time-tools=${TTP}/usr/bin
我不确定这是因为我错误地配置了GCC,还是因为“某些东西”不按照这种方式工作,或者crti.o文件应该从其他地方获取。
提前感谢
Allan W. Nielsen
--host=x86_64
到./configure
脚本来解决一个类似的问题,但不确定是否有帮助。 - ton