3

我正在使用 GCC4.7.0 开发 Mac OSX Lion,我的目标是编译一个 win32 交叉编译器。

GMP 和 MPFR,使用 Macports(以及 GCC47)安装。

使用的文件:

  • w32api-3.17-2-mingw32-dev.tar.lzma
  • mingwrt-3.20-mingw32-dev.tar.gz
  • binutils-2.22-1-mingw32-src.tar.lzma
  • src-gcc-4.7.0-release.tar.7z

Win32 api 和 mingw 运行时库,安装在此处:/opt/mingw

像这样编译 binutils 似乎工作正常:

 mkdir build
 cd build
 ../configure --prefix=/opt/mingw/ --target=i686-mingw32 --host=x86_64-apple-darwin \
   --build=x86_64-apple-darwin --with-libs=/opt/mingw/lib --with-headers=/opt/mingw/include \
   --with-gxx-include-dir=/opt/mingw/include/c++
 make
 sudo make install

所以下一步是编译 gcc,但这会导致错误,我使用的命令:

 mkdir build
 cd build
 ../configure --prefix=/opt/mingw/                                              \
          --with-gmp=/opt/local/ --with-mpfr=/opt/local/                        \
          --target=i686-mingw32 --host=x86_64-apple-darwin                      \
          --build=x86_64-apple-darwin --with-libs=/opt/mingw/lib                \
          --with-headers=/opt/mingw/include                                     \
          --with-gxx-include-dir=/opt/mingw/include/c++                         \
          --with-gcc --with-tune=generic --disable-werror                       \
          --disable-win32-registry --enable-sjlj-exceptions                     \
          --enable-libstdcxx-debug                                              \
          --enable-cxx-flags='-fno-function-sections -fno-data-sections'        \
          --enable-version-specific-runtime-libs                                \
          --disable-bootstrap --enable-threads --disable-nls                    \
          --enable-languages=c,c++
 make
 sudo make install

命令行错误:

//...
option to accept ISO C89... unsupported
checking how to run the C preprocessor... /lib/cpp
configure: error: in `/Users/Nik/Development/mingw-src/gcc-4.7.0/build/i686-mingw32/libgcc':
configure: error: C preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.
make[1]: *** [configure-target-libgcc] Error 1
make: *** [all] Error 2

config.log 可以在这里找到!

这是我第一次编译交叉编译器,这是一项相当复杂的任务,所以我希望有人能帮助我。

编辑:

似乎缺少一些常用的 c 头文件,但我不确定如何解决这个问题。

4

0 回答 0