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).
我有一些麻烦要在RHEL X86_64上安装GCC i686。实际上,我必须在这个平台上构建一些32位的软件和共享库。我可以在32位平台(linux或windows)上构建这些软件和库。
My questions are at the end of this post.
我的问题在这篇文章的最后。
My first problem was this error: (during a buil, under eclipse -helios)
我的第一个问题是这个错误(在一个buil,在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.
为了纠正这个错误,我不得不把stdlib放在这里。h包含在所有其他文件之前,但是我有很多文件,有时候这个技巧不管用。此外,我不应该修改源文件。
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).
当我使用一个朋友提供的makefile来构建一个共享库时,我也遇到了同样的问题。这个makefile在他的平台上运行良好(与我相同,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).
他告诉我出现了错误,因为我使用X86_64 lib,构建了一个32位的软件(或共享lib)。
Here's my version of GCC :
这是我的版本的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:
首先,我安装了glibc。i686 libgcc。来自RHEL DVD设置的i686包。现在我有:
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
因为GCC是x86_64,所以我阅读了一些关于交叉编译的文档,特别是这个: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).
所以我下载:gcc-4.4.6.tar。广州,binutils-2.23.tar。广州,gmp-5.0.2.tar。广州,mpfr-3.1.1.tar.gz。我将目录gmp-5.0.2和mpfr-3.1.1放在gcc-4.4.6目录中(我将gmp-5.0.2改为gmp, mpfr-3.1.1到mpfr)。
I followed the wiki.osdev instructions, that is:
我跟着wiki。osdev指令,即:
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'和'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 ...)
——>第1个错误:缺少“mpfr”。在“real.h“h”。所以我mpfr补充道。在gcc-4.4.6/gcc中,它是可以的(也许不是真的…)
--> 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 ?**
有什么好的办法解决失踪的ld强积金?** ?
I made a lot of research before posting. My linux knowledges are not very good at this time.
在发表之前我做了很多研究。我的linux知识在这个时候不太好。
Thank you in advance for your help.
提前谢谢你的帮助。
EDIT #1 :
编辑# 1:
I've already tried -m32 flag but the problem still here.
我已经试过了-m32,但问题还在这里。
For example, if I run a makefile:
例如,如果我运行一个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:
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 ...
对XXX来说一切都没问题。但是,下一个源文件出现了错误……
1 个解决方案
#1
4
It shouldn't be necessary to compile a 32bit version of GCC; just supply the -m32
flag to generate 32bit code with the 64bit version of GCC (FAQ entry).
不需要编译一个32位版本的GCC;只需提供-m32标记,以生成32位代码,并使用64位版本的GCC (FAQ条目)。
This question supports this: How to compile glibc 32bit on an x86_64 machine
这个问题支持:如何在x86_64机器上编译glibc 32位。
Note that you might have to install 32bit versions and devel packages of all the dependencies of the code that you want to compile (i.e. linux header files, glibc, ...)
注意,您可能需要安装32位版本和所有要编译的代码的依赖项(例如,linux头文件,glibc,…)
EDIT To debug problems like that, it's often useful to see the source which GCC tries to compile. For this, use gcc -E
instead of gcc -c
. That will give you the preprocessed C source plus a lot #line
statements which tell what file GCC was reading to produce what follows.
编辑来调试这样的问题,经常可以看到GCC试图编译的源代码。为此,使用gcc -E而不是gcc -c。这将为您提供预处理的C源和许多#行语句,这些语句告诉您GCC正在读取什么文件来生成下面的内容。
Create such a file and examine it. The errors above make me wonder if you created a preprocessor macro which expands to something unexpected in stdlib.h
.
创建这样一个文件并检查它。上面的错误使我怀疑您是否创建了一个预处理器宏,它扩展到stdlib.h中意外的内容。
#1
4
It shouldn't be necessary to compile a 32bit version of GCC; just supply the -m32
flag to generate 32bit code with the 64bit version of GCC (FAQ entry).
不需要编译一个32位版本的GCC;只需提供-m32标记,以生成32位代码,并使用64位版本的GCC (FAQ条目)。
This question supports this: How to compile glibc 32bit on an x86_64 machine
这个问题支持:如何在x86_64机器上编译glibc 32位。
Note that you might have to install 32bit versions and devel packages of all the dependencies of the code that you want to compile (i.e. linux header files, glibc, ...)
注意,您可能需要安装32位版本和所有要编译的代码的依赖项(例如,linux头文件,glibc,…)
EDIT To debug problems like that, it's often useful to see the source which GCC tries to compile. For this, use gcc -E
instead of gcc -c
. That will give you the preprocessed C source plus a lot #line
statements which tell what file GCC was reading to produce what follows.
编辑来调试这样的问题,经常可以看到GCC试图编译的源代码。为此,使用gcc -E而不是gcc -c。这将为您提供预处理的C源和许多#行语句,这些语句告诉您GCC正在读取什么文件来生成下面的内容。
Create such a file and examine it. The errors above make me wonder if you created a preprocessor macro which expands to something unexpected in stdlib.h
.
创建这样一个文件并检查它。上面的错误使我怀疑您是否创建了一个预处理器宏,它扩展到stdlib.h中意外的内容。