linux版本i686,linux-x86_64平台上的gcc i686

我在RHEL X86_64上安装GCC i686时遇到一些麻烦.

确实,我必须在此平台上构建一些32位软件和共享库.

我可以在32位平台(Linux或Windows)上构建这些软件和库.

我的问题在这篇文章的结尾.

我的第一个问题是这个错误:(在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

要更正此错误,我必须将stdlib.h include放在所有其他文件之前,但是我有很多文件,有时此技巧还是不管用.

而且,我不应该修改源文件.

使用朋友提供的makefile构建共享库时,我遇到完全相同的问题.

这个makefile在他的平台上运行良好(与我相同,RHEL 4.4.6 x86_64).

他告诉我出现错误是因为我使用X86_64 lib来构建32位软件(或共享库).

这是我的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

因此,首先,我从RHEL DVD安装程序安装了glibc.i686和libgcc.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

由于GCC是x86_64,因此我阅读了一些有关交叉编译的文档,尤其是以下文档:

wiki.osdev.org/GCC_Criss-Compiler

所以我下载了:gcc-4.4.6.tar.gz,binutils-2.23.tar.gz,gmp-5.0.2.tar.gz和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).

我遵循了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 \n --enable-languages=c,c++ --without-headers

make all-gcc

make install-gcc

> binutils的’make all’和’make install’=>好

>“制作全gcc”

->第一个错误:“ real.h”中缺少“ mpfr.h”.所以我在gcc-4.4.6 / gcc中添加了mpfr.h,这样就可以了(也许实际上不是…)

->第2个错误(目前唯一的错误):

[...]

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 \n 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**

**最后,我的问题是:

>这种交叉编译是否可以解决我的问题?

>解决ld mpfr丢失问题的好方法是什么?**

发布前,我做了很多研究.我的Linux知识目前还不是很好.

预先感谢您的帮助.

?编辑#1:

我已经尝试过-m32标志,但是问题仍然存在.

例如,如果我运行一个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

这是XXX.c:

#include "alphabet.h"

#include "outils.h"

#include "erreur.h"

#include

#include (line 51 error)

如果以这种方式修改:

#include

#include "alphabet.h"

#include "outils.h"

#include "erreur.h"

#include

XXX.c一切正常,但下一个源文件出现错误…

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值