我在
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)?
我想知道Y如何在x86机器上为SPARC编译? 在哪里可以找到好的交叉编译器?我还需要针对HP OS进行编译.
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.
推荐答案gcc完全有能力做到这一点. Sun的编译器也许可以,但是我对gcc更为熟悉.首先,您应该熟悉构建gcc,并确定是否只需要C编译器,还是需要C ++或其他语言.
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.
一旦为所在的主机构建了gcc,则可以重新构建gcc以包含要交叉编译的目标计算机的目标.
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.
- 构建:您正在构建的机器
- 主机:您要为其构建的计算机
- 目标:以及GCC将为其生成代码的机器
对于交叉编译器,build和host相同,而目标则不同.例如,以下是告诉编译器构建可从Solaris x86交叉编译到Solaris Sparc的编译器的方法:
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.
在同时运行32位和64位可执行文件的平台上进行编译非常容易.其他任何事情都会有些棘手. Mac上的gcc具有多个目标,而Apple使得为多个平台创建二进制文件变得相当容易.所有iPhone应用程序均在x86上编译,并以ARM处理器为目标.如果您可以为所需的目标构建编译器,那么交叉编译通常很容易做到.
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.
更多推荐
在x86上交叉编译SPARC
发布评论