64位linux上gcc-4.6.2编译32位程序链接报错:crtbegin.o: could not read symbols: File in wrong format?


我在64位的linux机器上从源码安装了gcc-4.6.2,安装配置如下:
Configured with: ../gcc-4.6.2/configure --prefix=/usr/local/gcc-4.6.2 --mandir=/usr/share/man --infodir=/usr/share/info --enable-bootstrap --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++ --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-1.0.1 --without-ppl --without-cloog --with-arch-32=i686 --build=x86_64-redhat-linux --disable-multilib

安装成功后可以编译64位程序,但是当我使用-m32选项来编译32位程序时报错了,错误如下:
/usr/local/gcc-4.6.2/lib/gcc/x86_64-redhat-linux/4.6.2/crtbegin.o: could not read symbols: File in wrong format

我不知道是不是gcc的编译配置不正确还是什么其他问题导致这个错误。我尝试了google寻找答案,但是没有找到能够帮到我的信息。希望各位专家们帮忙看看这个问题,非常感谢!

gcc

老萨满与海 11 years, 3 months ago

file crtbegin.o 看一下文件格式,应该是64bit吧?
虽然gcc支持编译32bit的,但还要有32bit的C库和头文件。你看看你linux是什么发行版的,安装对应的32bit基础库再试试。

乱投硬币打死 answered 11 years, 3 months ago

Your Answer