从源代码在64位上构建32位GCC:链接问题 [英] Building 32 bit GCC from source on 64 bit: linking issue
问题描述
/usr/bin/ld: i386:x86-64 architecture of input file `build/gengenrtl.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `build/errors.o' is incompatible with i386 output
/usr/bin/ld: build/gengenrtl.o: file class ELFCLASS64 incompatible with ELFCLASS32
/usr/bin/ld: final link failed: File in wrong format
collect2: error: ld returned 1 exit status
如果问题是ld
或给定的库,我不知道.
I don't get if the problem is ld
or the given library.
我的配置是
CC="gcc -m32" \
CFLAGS="-m32" \
LD="<path>/bin/32/binutils/2.23.2/bin/ld" \
LDFLAGS="-m32" \
./configure \
--build=i586-pc-linux-gnu \
--host=i586-pc-linux-gnu \
--target=i586-pc-linux-gnu \
--enable-shared \
--enable-static \
--enable-languages=c,c++ \
--enable-bootstrap \
--prefix=<path>/bin/32/gcc/i586 \
--disable-stage1-checking \
--with-gmp=<path>/lib/32/gmp/5.1.2 \
--with-mpfr=<path>/lib/32/mpfr/3.1.2 \
--with-mpc=<path>/lib/32/mpc/1.0.1 \
--with-cloog=<path>/lib/32/cloog/0.18.0 \
--without-ppl
显然,我无法轻易更改ld可执行文件,gcc始终使用全局系统/usr/bin/ld
进行编译.
Apparently I can't change the ld executable so easily, gcc keeps compiling with the global system /usr/bin/ld
.
有人可以说这是怎么回事,以及如何解决此链接阶段?
Someone can say what is going on here and how to fix this linking phase ?
我在Ubuntu 64位环境下,我正在尝试编译32位版本的gcc,当然我已经为32位编译了gmp,mpc,mpfr.
I'm under Ubuntu 64 bit and I'm trying to compile a 32 bit build of gcc, of course I have already compiler gmp, mpc, mpfr for 32 bits.
推荐答案
课程 ,您可以使用64位OS,编译器和链接程序从源代码以32位形式构建gcc.问题绝对不是"ld".
Of course you can build gcc from source as 32-bit, using a 64-bit OS, compiler and linker. The problem is definitely not "ld".
您做的完全正确:在CFLAGS和LDFLAGS中指定"-m32".
You're doing exactly the right thing: specifying "-m32" in CFLAGS and LDFLAGS.
问题是build/gengenrtl.o
和build/errors.o
似乎是为64位(而不是32位)构建的.
The problem is that build/gengenrtl.o
and build/errors.o
appear to have been built for 64-bit (instead of 32-bit).
建议:
1)检查makefile,并检查您的构建日志.看看这两个文件的构建命令是否有任何不同".
1) Check the makefile, and check your build log. See if there's anything "different" about the build commands for those two files.
2)使用"nm"命令来验证其余* .o对象文件是否正确构建为32位-仅(错误地)仅将"gengenrtl.o"和"errors.o"构建为32位. ELFCLASS64.
2) Use the "nm" command to verify that the rest of your *.o object files were correctly built as 32-bit - that only "gengenrtl.o" and "errors.o" were (incorrectly) built as ELFCLASS64.
'希望有帮助...
这篇关于从源代码在64位上构建32位GCC:链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!