问题描述
我正在尝试构建一个交叉编译器,x86_64 是主机,i386 是目标.我得到了(所有常见的)crti.o:没有这样的文件错误.而不是从发行版中获取已经构建的 crti.o 和 crtn.o...我该如何从 glibc(或可能是 gcc)源中明确构建这些文件?
I am trying to build a cross-compiler with x86_64 being the host and i386 being the target. I'm getting the (all to common) crti.o: No such file error. Instead of grabbing an already built crti.o and crtn.o from a distro... how might I go about building these files explicitly from glibc (or possibly gcc) sources?
仅供参考,我很清楚 x86_64 编译器的 -m32 选项.我更喜欢只有 32 位的编译器环境.另外,我不想使用任何已经构建的 i386 编译器的原因是因为我计划根据我的测试需要混合和匹配 glibc/binutils/gcc 版本.
FYI, I am well aware of the -m32 option for x86_64 compilers. I'd prefer to just have a 32bit-only compiler environment. Also, the reason I don't want to use any of the gazillion already build i386 compilers is because I plan on mixing and matching glibc/binutils/gcc versions depending on my testing needs.
谢谢,陈兹
推荐答案
您确定您使用的交叉编译配置正确吗?应该是
Are you sure you're using configuring the cross-compile correctly? It should be
CBUILD = CHOST = x86_64-pc-linux-gnu
CTARGET = i386-pc-linux-gnu
当您在 x86_64
上运行构建时,编译器将在 x86_64
上运行,从而为 i386
生成代码.
as you're running a build on an x86_64
, for a compiler to run on an x86_64
, which generates code for an i386
.
如果您使用 CHOST = i386-pc-linux-gnu
,您将尝试生成 32 位二进制文件,这需要与 32 位 libc.如果您已经拥有 32 位
libc
,这很好,但听起来您没有.
If you used
CHOST = i386-pc-linux-gnu
, you'll be trying to generate 32-bit binaries, which will need to link with a 32-bit libc
. Which is fine, if you already have a 32-bit libc
, but it sounds like you don't.
即
$ tar xvjf gcc-*.tar.bz2
$ cd gcc-*/
$ mkdir build
$ cd build
$ ../configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=i386-pc-linux-gnu
这篇关于为 i386 构建 crti.o的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!