Cross compiling for SPARC on x86

女生的网名这么多〃 提交于 2019-12-10 10:43:58

问题


I've seen the about cross compilers reply at How do I cross-compile C code on Windows for a binary to also be run on Unix (Solaris/HPUX/Linux)?

I would like to know how can Y compile for SPARC on a x86 machine? Where can i find a good cross compiler? I also need to compile for HP OS.


回答1:


gcc is fully capable of this. Sun's compiler may be capable, but I'm more familiar with gcc. First, you should get comfortable with building gcc, and also decide if you need just the C compiler or if you need C++ or other languages.

Once you've built gcc for the host you are on, you can then rebuild gcc to include a target for the target machine you want to cross compile for.

When building a cross compiler, the three things you must get correct are the build, host, and target.

  • build: the machine you are building on
  • host: the machine that you are building for
  • target: and the machine that GCC will produce code for

For a cross compiler, build and host will be the same, and target will be different. For example, here's how to tell the compiler to build a compiler to cross compile from Solaris x86 to Solaris Sparc:

./configure --build=x86_64-sun-solaris2.10 --host=x86_64-sun-solaris2.10 --target=sparc-sun-solaris2.10

You can then build additional compiler for each target you need to cross compile to.

Compiling 32 bit and 64 bit executables on a platform which runs both is quite easy. Anything else, will be a bit trickier. gcc on the Mac is built with several targets, and Apple has made it quite easy to create binaries for multiple platforms. All iPhone apps are compiled on x86 and target the ARM processor. If you can get the compiler built for the targets you want, then the cross compiling is usually fairly easy to do.



来源:https://stackoverflow.com/questions/2403022/cross-compiling-for-sparc-on-x86

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