solaris-编译64位gcc-elf类错误

solaris-编译64位gcc-elf类错误,gcc,compilation,solaris,elf,gmp,Gcc,Compilation,Solaris,Elf,Gmp,我正在solaris上安装gcc的现代版本。我编译了gmp、mpfr和mpc,它们都是64位的。当我尝试如下配置gcc时,我得到一个错误,抱怨mpc、mpfr和gmp是错误的elf类。有什么好处 ./../gcc-4.5.1/configure --prefix=/opt/OurAppDir/gcc --with-gmp=/opt/OurAppDir/gmp --with-mpfr=/opt/OurAppDir/mpfr --with-gnu-as --with-gnu-ld --build=s

我正在solaris上安装gcc的现代版本。我编译了gmp、mpfr和mpc,它们都是64位的。当我尝试如下配置gcc时,我得到一个错误,抱怨mpc、mpfr和gmp是错误的elf类。有什么好处

./../gcc-4.5.1/configure --prefix=/opt/OurAppDir/gcc --with-gmp=/opt/OurAppDir/gmp --with-mpfr=/opt/OurAppDir/mpfr --with-gnu-as --with-gnu-ld --build=sparc-sun-solaris2.10
checking build system type... sparc-sun-solaris2.10
checking host system type... sparc-sun-solaris2.10
checking target system type... sparc-sun-solaris2.10
checking for a BSD-compatible install... ./../gcc-4.5.1/install-sh -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp $$f1 $$f2 16 16
checking for objdir... .libs
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... no
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.
config.log错误

configure:5474: checking for the correct version of gmp.h
configure:5494: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5494: $? = 0
configure:5512: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5512: $? = 0
configure:5513: result: yes
configure:5529: checking for the correct version of mpfr.h
configure:5547: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5547: $? = 0
configure:5564: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5564: $? = 0
configure:5565: result: yes
configure:5582: checking for the correct version of mpc.h
configure:5599: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5599: $? = 0
configure:5615: gcc -c -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   conftest.c >&5
configure:5615: $? = 0
configure:5616: result: yes
configure:5634: checking for the correct version of the gmp/mpfr/mpc libraries
configure:5665: gcc -o conftest -g -O2 -I/opt/OurAppDir/gmp/include -I/opt/OurAppDir/mpfr/include   -R/usr/sfw/lib/sparcv9 conftest.c  -L/opt/OurAppDir/gmp/lib -L/opt/OurAppDir/m
pfr/lib -lmpc -lmpfr -lgmp >&5
ld: fatal: file /opt/OurAppDir/mpfr/lib/libmpc.so: wrong ELF class: ELFCLASS64
ld: fatal: file /opt/OurAppDir/mpfr/lib/libmpfr.so: wrong ELF class: ELFCLASS64
ld: fatal: file /opt/OurAppDir/gmp/lib/libgmp.so: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to conftest

使用默认配置行,GCC将不会构建为64位二进制文件,而是32位二进制文件。因此,您需要通过强制
configure ABI=32
在32位模式下重建GMP、MPFR和MPC


或者,您可以使用
sparc64 sun solarisX
build三元组配置GCC。在这种情况下,在GCC网站上有。构建64位应用程序不需要64位GCC二进制文件。OpenCSW Solaris软件包提供32位编译器,目标为32位和64位

我假设您更关心的是能够从gcc生成64位二进制文件,而不是gcc本身是64位的

要同时构建32位和64位目标,您需要构建两次gmp,一次是32位,一次是64位。然后您就有了以下布局(示例取自包的pkgmap):

GCC构建系统足够智能,可以查看64位库的
/opt/csw/lib/sparcv9
,以及32位库的
/opt/csw/lib

gmp.h
头文件是一个包装器,它包含一个
#ifdef
语句,包括
gmp-32.h
gmp-64.h
,具体取决于请求的编译模式

/* Allow 32 and 64 bit headers to coexist */
#if defined __amd64 || defined __x86_64 || defined __sparcv9
#include "gmp-64.h"
#else
#include "gmp-32.h"
#endif
gmp库是唯一需要这种头文件包装的库;mpc、mpfr、ppl和cloog库不会因体系结构/字长的不同而改变头文件

当您使用64位目标编译gcc时,您会得到一个包含两个crt1.o文件的布局:

/opt/csw/lib/gcc/sparc-sun-solaris2.9/4.6.2/crt1.o
/opt/csw/lib/gcc/sparc-sun-solaris2.9/4.6.2/sparcv9/crt1.o

这样,当您传递-m64时,gcc将生成一个64位二进制文件。

谢谢,我尝试用--build=sparc64-sun-solaris2.10配置gcc,但仍然得到相同的错误。.so文件的eld类是ELFCLASS64,所以我不明白如果我提供了构建参数,为什么仍然会出现此错误。默认情况下,系统编译器是否也生成64位代码?如果没有,您还需要
CC='gcc-m64'
或同等产品。总而言之,我建议使用32位,这肯定更简单。
/opt/csw/lib/gcc/sparc-sun-solaris2.9/4.6.2/crt1.o
/opt/csw/lib/gcc/sparc-sun-solaris2.9/4.6.2/sparcv9/crt1.o