RHEL X86_64 に GCC i686 をインストールするのに問題があります。実際、このプラットフォームで 32 ビット ソフトウェアと共有ライブラリを構築する必要があります。これらのソフトウェアとライブラリを 32 ビット プラットフォーム (Linux または Windows) で構築できます。
私の質問はこの投稿の最後にあります。
私の最初の問題はこのエラーでした:(ビルド中、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 インクルードを配置する必要がありましたが、多くのファイルがあり、とにかくこのトリックが機能しない場合がありました。さらに、ソース ファイルを変更しないでください。
友人から提供されたメイクファイルを使用して共有ライブラリを構築する場合、まったく同じ問題が発生します。この makefile は、彼のプラットフォーム (私と同じ RHEL 4.4.6 x86_64) でうまく機能します。
X86_64 ライブラリを使用して 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 であるため、クロス コンパイルに関するドキュメントをいくつか読み ました。
そこで、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 \
--enable-languages=c,c++ --without-headers
make all-gcc
make install-gcc
- ' make all ' と ' make install ' for binutils => OK
- ' make all-gcc '
--> 最初のエラー: "real.h" に "mpfr.h" がありません。そこで gcc-4.4.6/gcc に mpfr.h を追加してみたらOKでした(実際は違うかも…)
--> 2 番目のエラー (現在は 1 つだけ):
[...]
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**
**最後に、私の質問は次のとおりです。
このクロスコンパイルは私の問題を解決できますか?
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 <string.h>
#include <stdlib.h> (line 51 error)
このように変更する場合:
#include <stdlib.h>
#include "alphabet.h"
#include "outils.h"
#include "erreur.h"
#include <string.h>
XXX.c については問題ありませんが、次のソース ファイルでエラーが表示されます...