x86 上 SPARC 的交叉编译

发布于 2024-08-25 01:36:08 字数 300 浏览 1 评论 0原文

我已经看到关于交叉编译器的回复 如何在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执着的年纪 2024-09-01 01:36:09

gcc完全有能力做到这一点。 Sun的编译器可能有能力,但我更熟悉gcc。首先,您应该熟悉构建 gcc,并决定是否只需要 C 编译器,还是需要 C++ 或其他语言。

一旦您为所在的主机构建了 gcc,您就可以重建 gcc 以包含您想要交叉编译的目标机器的目标。

构建交叉编译器时,必须正确的三件事是构建、主机和目标。

  • build:您正在构建的机器
  • host:您正在为
  • target 构建的机器:以及 GCC 将为其生成代码的机器

对于交叉编译器,build 和 host 将相同,而 target 将不同。例如,以下是如何告诉编译器构建一个编译器以从 Solaris x86 交叉编译到 Solaris Sparc:

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

然后,您可以为需要交叉编译的每个目标构建附加编译器。

在运行 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.

  • 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文