交叉编译时缺少crt1和crti

All*_*lan 5 linker gcc 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
Run Code Online (Sandbox Code Playgroud)

在安装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
Run Code Online (Sandbox Code Playgroud)

从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} 
Run Code Online (Sandbox Code Playgroud)

以下是我在编译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 
Run Code Online (Sandbox Code Playgroud)

我确定这是否是由于我错误地配置了GCC,或者"东西"根本不起作用,或者文件crti.o应该来自其他地方.

提前致谢

艾伦W.尼尔森

F'x*_*F'x 1

有些crt*文件不是来自编译器,而是来自 C 库。crt1.o我怀疑您的和就是这种情况crti.o