x86 上 SPARC 的交叉编译
我已经看到关于交叉编译器的回复 如何在 Windows 上交叉编译 C 代码以使二进制文件也可以在 Unix (Solaris/HPUX/Linux) 上运行?
我想了解如何在 x86 机器上为 SPARC 进行 Y 编译? 哪里可以找到好的交叉编译器?我还需要针对 HP 操作系统进行编译。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
gcc完全有能力做到这一点。 Sun的编译器可能有能力,但我更熟悉gcc。首先,您应该熟悉构建 gcc,并决定是否只需要 C 编译器,还是需要 C++ 或其他语言。
一旦您为所在的主机构建了 gcc,您就可以重建 gcc 以包含您想要交叉编译的目标机器的目标。
构建交叉编译器时,必须正确的三件事是构建、主机和目标。
对于交叉编译器,build 和 host 将相同,而 target 将不同。例如,以下是如何告诉编译器构建一个编译器以从 Solaris x86 交叉编译到 Solaris Sparc:
然后,您可以为需要交叉编译的每个目标构建附加编译器。
在运行 32 位和 64 位可执行文件的平台上编译这两种可执行文件非常容易。其他任何事情都会有点棘手。 Mac 上的 gcc 是由多个目标构建的,Apple 使为多个平台创建二进制文件变得非常容易。所有 iPhone 应用程序均在 x86 上编译并以 ARM 处理器为目标。如果您可以获得为您想要的目标构建的编译器,那么交叉编译通常相当容易完成。
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.
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:
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.