交叉编译时缺少crt1和crti [英] Missing crt1 and crti when crosscompiling

查看:843
本文介绍了交叉编译时缺少crt1和crti的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  ld:error:无法打开crti.o :没有这样的文件或目录
ld:错误:无法打开crtn.o:没有这样的文件或目录
ld:错误:找不到-lc

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

  find ../../../tooltarget/ -namecrt *-print#(结果被修改为消耗更少的空间)
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:crtbegin所以
%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

解决方案

部分 crt * 不是来自编译器,而是来自C库。我怀疑这是您的 crt1.o crti.o


I'am trying to build a cross compile toolchain based on GCC4.5 and newlib with gold and link-time-optimization enabled. GCC compiles fine but it did not generate the crt1.o or crti.o files. Therefore when I tries to use the compiler for building Newlib it complains with the message:

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

When searching for files named crt* in the directory where GCC4.5 is installed i got the following result:

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

From the GCC spec's it seems like gcc needs both the crtbegin.o and the crti.o files, but only one of them is available.

*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} 

Following is the flags i used when compiling 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 

I'm sure on if this is due to I configured GCC wrongly, or "stuff" simply do not work this way, or if the files crti.o should come from somewhere else.

Thanks in advance

Allan W. Nielsen

解决方案

Some crt* files come not from the compiler, but from the C library. I suspect this is the case here for your crt1.o and crti.o.

这篇关于交叉编译时缺少crt1和crti的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆