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一切正常,但下一個源文件出現錯誤…
總結
以上是生活随笔為你收集整理的linux版本i686,linux-x86_64平台上的gcc i686的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java SSM篇5——SpringMV
- 下一篇: WINDOWS下对音频的处理过程(转)