2010-07-21 178 views
5

我试图建立一个基于GCC4.5和newlib的交叉编译工具链,并启用了黄金和链接时优化。 GCC编译得很好,但没有生成crt1.o或crti.o文件。因此,当我尝试使用编译器来编译Newlib它与消息抱怨:交叉编译时缺少crt1和crti

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 

当名为CRT *在GCC4.5安装我得到了以下结果目录中的文件搜索:

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应该来自其他地方。

在此先感谢

艾伦·W·尼尔森

+1

[crti.o文件丢失]的可能重复(http://stackoverflow.com/questions/91576/crti-o-file-missing) – user2284570 2014-07-19 09:14:17

+0

我刚刚解决了这样一个问题,使用gcc build添加'--host = x86_64'到'。/ configure'脚本,但不知道是否有帮助。 – ton 2017-02-19 00:11:27

回答

1

一些crt*文件不是来自编译器,但是从C库。我怀疑这是你的情况crt1.ocrti.o

+0

不,有ctr1.S和crti.S,它们是在gcc构建时由脚本生成的。 – user2284570 2014-07-19 09:16:17