交叉编译时缺少crt1和crti

时间:2010-07-21 13:05:59

标签: gcc linker cross-compiling

我正在尝试构建基于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

1 个答案:

答案 0 :(得分:1)

某些crt*文件不是来自编译器,而是来自C库。我怀疑这是crt1.ocrti.o

的情况