I have some troubles to install GCC i686 on a RHEL X86_64. Indeed, I have to build some 32bit softwares and shared libraries on this platform. I can build these softwares and libraries on 32bit platforms (linux or windows).
My questions are at the end of this post.
My first problem was this error: (during a buil, under eclipse -helios)
In file included from /usr/include/stdlib.h:314,
from ../../../../../XXXX.h:19,
from /XXXX.c:33:
/usr/include/sys/types.h:150: error: duplicate 'unsigned'
/usr/include/sys/types.h:151: error: duplicate 'unsigned'
/usr/include/sys/types.h:151: error: duplicate 'short'
/usr/include/sys/types.h:152: error: duplicate 'unsigned'
/usr/include/sys/types.h:152: error: two or more data types in declaration specifiers
make: *** [XXXX.o] Error 1
To correct this error, I had to put the stdlib.h include before all the other files, but I have a lot of files, and sometimes this trick did not work anyway. Moreover, I should not modify the source files.
I have exactly the same problem when I use a makefile given by a friend, to build a shared library. This makefile works well on his platform (the same as me, RHEL 4.4.6 x86_64).
He told me the error appears because I use X86_64 lib, to build a 32bits software (or shared lib).
Here's my version of GCC :
GCC version
[root@localhost bin]# gcc -v
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr
--mandir=/usr/share/man
--infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap
--enable-shared
--enable-threads=posix
--enable-checking=release
--with-system-zlib
--enable-__cxa_atexit
--disable-libunwind-exceptions
--enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk
--disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile
--enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--disable-libjava-multilib
--with-ppl
--with-cloog
--with-tune=generic
--with-arch_32=i686
--build=x86_64-redhat-linux
thread: posix
gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
[root@localhost bin]# rpm -qa |grep gcc
gcc-c++-4.4.6-3.el6.x86_64
gcc-4.4.6-3.el6.x86_64
gcc-gfortran-4.4.6-3.el6.x86_64
So first, I installed glibc.i686 and libgcc.i686 packages from the RHEL DVD setup. Now I have:
Installed packages (from redhat DVD)
[root@localhost bin]# rpm -qa |grep glibc
glibc-common-2.12-1.47.el6.x86_64
glibc-2.12-1.47.el6.x86_64
glibc-devel-2.12-1.47.el6.x86_64
glibc-devel-2.12-1.47.el6.i686
glibc-headers-2.12-1.47.el6.x86_64
glibc-2.12-1.47.el6.i686
[root@localhost bin]# rpm -qa |grep libgcc
libgcc-4.4.6-3.el6.x86_64
libgcc-4.4.6-3.el6.i686
Since GCC is x86_64, I read some documents about the cross compilation, espcially this one: wiki.osdev.org/GCC_Criss-Compiler
So I downloaded: gcc-4.4.6.tar.gz, binutils-2.23.tar.gz, gmp-5.0.2.tar.gz, and mpfr-3.1.1.tar.gz. I put the directories gmp-5.0.2 and mpfr-3.1.1 in gcc-4.4.6 directory (and I renamed gmp-5.0.2 to gmp, and mpfr-3.1.1 to mpfr).
I followed the wiki.osdev instructions, that is:
export PREFIX=/usr/local/cross
export TARGET=i686-elf
cd /usr/src
mkdir build-binutils build-gcc
cd /usr/src/build-binutils
../binutils-x.xx/configure --target=$TARGET --prefix=$PREFIX --disable-nls
make all
make install
cd /usr/src/build-gcc
export PATH=$PATH:$PREFIX/bin
../gcc-x.x.x/configure --target=$TARGET --prefix=$PREFIX --disable-nls \
--enable-languages=c,c++ --without-headers
make all-gcc
make install-gcc
- 'make all' and 'make install' for binutils => OK
- 'make all-gcc'
--> 1st error: missing "mpfr.h" in "real.h". So I added mpfr.h in gcc-4.4.6/gcc and it was OK (maybe not actually ...)
--> 2nd error (the only one now):
[...]
gcc -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall
-Wwrite-strings
-Wstrict-prototypes
-Wmissing-prototypes
-Wcast-qual
-Wold-style-definition
-Wc++-compat
-Wmissing-format-attribute
-pedantic
-Wno-long-long
-Wno-variadic-macros
-Wno-overlength-strings
-DHAVE_CONFIG_H
-o cc1-dummy c-lang.o stub-objc.o attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o
c-typeck.o c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o
c-ppoutput.o c-cppbuiltin.o c-objc-common.o c-dump.o c-pch.o c-parser.o i386-c.o
c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o dummy-checksum.o \
main.o libbackend.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a ../libcpp/libcpp.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a
-L/usr/src/build-gcc/./gmp/.libs -L/usr/src/build-gcc/./gmp/_libs
-L/usr/src/build-gcc/./mpfr/.libs -L/usr/src/build-gcc/./mpfr/_libs
-lmpfr -lgmp
**/usr/bin/ld: cannot find -lmpfr
collect2: ld returned 1 exit status
make[1]: *** [cc1-dummy] Error 1
make[1]: Leaving directory `/usr/src/build-gcc/gcc'
make: *** [all-gcc] Error 2**
**Finally, my questions are :
Is this cross-compilation can resolve my problem ?
What is the good way to resolve the problem of the missing ld mpfr ?**
I made a lot of research before posting. My linux knowledges are not very good at this time.
Thank you in advance for your help.
EDIT #1 :
I've already tried -m32 flag but the problem still here.
For example, if I run a makefile:
[root@localhost makefile]# make -f sharedLib.mak
gcc -m32 -march=i686 -O2 -Wall -I ../../sharedLib/inc/ -o XXX.o -c ../src/XXX.c
In file included from /usr/include/stdlib.h:314,
from ../src/XXX.c:51:
/usr/include/sys/types.h:150: error: duplicate 'unsigned'
/usr/include/sys/types.h:151: error: duplicate 'unsigned'
/usr/include/sys/types.h:151: error: duplicate 'short'
/usr/include/sys/types.h:152: error: duplicate 'unsigned'
/usr/include/sys/types.h:152: error: two or more data types in declaration specifiers
make: *** [XXX.o] Error 1
Here's XXX.c:
#include "alphabet.h"
#include "outils.h"
#include "erreur.h"
#include <string.h>
#include <stdlib.h> (line 51 error)
If a modify this way:
#include <stdlib.h>
#include "alphabet.h"
#include "outils.h"
#include "erreur.h"
#include <string.h>
Everything is OK for XXX.c but the error appears for the next source file ...