I'm installing a modern version of gcc on solaris. I compiled gmp, mpfr and mpc, they're all 64bit. When I try to configure gcc as follows I get an error complaining that mpc,mpfr and gmp are the wrong elf class. What gives?
./../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 errors
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 E开发者_StackOverflow中文版LF 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
With the default configure line, GCC will not be built as a 64-bit binary, but as 32-bit. So, you need to rebuild GMP, MPFR and MPC in 32-bit mode, by forcing configure ABI=32
.
Alternatively, you can configure GCC with a sparc64-sun-solarisX
build triplet. In that case, there are additional instructions on the GCC website.
You don't need 64-bit gcc binaries in order to build 64-bit application. The OpenCSW Solaris packages provide 32-bit compiler with 32-bit and 64-bit targets.
I assume you care more about being able to generate 64-bit binaries from your gcc, and less about gcc itself being 64-bit.
The way to build both 32-bit and 64-bit targets, you need to build gmp two times, once 32-bit and once 64-bit. Then you have the following layout (the example is taken from package's pkgmap):
1 f none /opt/csw/include/gmp-32.h 0644 root bin 86213 38841 1316878625
1 f none /opt/csw/include/gmp-64.h 0644 root bin 86218 39139 1316879685
1 f none /opt/csw/include/gmp.h 0755 root bin 159 12880 1316879688
1 f none /opt/csw/include/gmpxx-32.h 0644 root bin 114646 51865 1316878625
1 f none /opt/csw/include/gmpxx-64.h 0644 root bin 114646 51865 1316879685
1 f none /opt/csw/include/gmpxx.h 0755 root bin 163 13360 1316879688
1 s none /opt/csw/lib/libgmp.so=libgmp.so.10.0.2
1 s none /opt/csw/lib/libgmpxx.so=libgmpxx.so.4.2.2
1 s none /opt/csw/lib/libgmp.so.10=libgmp.so.10.0.2
1 f none /opt/csw/lib/libgmp.so.10.0.2 0755 root bin 462552 51359 1316878625
1 s none /opt/csw/lib/sparcv9/libgmp.so.10=libgmp.so.10.0.2
1 f none /opt/csw/lib/sparcv9/libgmp.so.10.0.2 0755 root bin 503424 11223 1316879684
The GCC build system is smart enough to know to look into /opt/csw/lib/sparcv9
for the 64-bit libraries and into /opt/csw/lib
for the 32-bit libraries.
The gmp.h
header file is a wrapper, which contains an #ifdef
statement, including gmp-32.h
or gmp-64.h
depending on the compilation mode requested.
/* 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
The gmp library is the only one which requires this kind of header file wrapper; the mpc, mpfr, ppl and cloog libraries don't vary the header files depending on the architecture / word length.
When you compile gcc with 64-bit targets, you get a layout with two crt1.o files:
/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
This way, when you pass -m64, gcc will produce a 64-bit binary.
精彩评论