Getting GMP to work with GCC 4.5.2

孤街醉人 提交于 2019-12-06 12:11:18

I think that you are confused about which package should be compiled for which platform:

  • GCC needs to be compiled for an x86_64 MacOS X host and an i386-linux target.

  • GMP, MPC and MPFR are runtime dependencies for GCC. Therefore they also need to be compiled for the GCC host - x86_64 in your case. Therefore, the --host=i386-linux option in the GMP configure command is incorrect.

In general, only libraries that will be linked in the programs compiled by GCC need to be built for the cross-compiler target (e.g. i386-linux). GMP and MPFR are not such libraries, unless your programs are actually using them - in that case you will need to have two copies of such libraries, one for GCC and a cross-build for the target.

EDIT:

Have you considered using MacPorts? It has all the dependencies for your cross-compiler:

There is also an older newlib-based cross-compiler for i386:

Even if you do not want to use these, you can still have a look at the build instructions in their Portfiles.

The bottom line is:

  • Apply whatever patches these libraries need - MacPorts already do that.

  • Compile the libraries for your build host i.e. MacOSX/x86_64. That means that in any --host options for their configure calls you should be something along the lines of --host=x86_64-darwin (or whatever your host needs). If configure can figure out the host on its own, you can skip the --host options altogether.

  • Compile GCC with --host being your build host (the 64-bit Mac OS X) and a target of i386-linux, e.g. --target=i386-linux. If I were you, I'd start simple with a compiler for the C and C++ languages only.

See also this tutorial. It has some information on how to produce a working toolchain with a proper glibc.

That said, I think that you'd be better off installing a proper Linux distribution in a virtual machine, for a whole bunch of reasons. Is there a reason for you to need a cross-compiler specifically? What do you want to do with that compiler?

Did you use the "ABI=32" option when compiling GMP? If not, I think it will use 64-bit code even if the host/target are specified as i386.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!