在Mac OS X上构建跨工具链的最佳方法 [英] Best way to build cross toolchains on Mac OS X

查看:272
本文介绍了在Mac OS X上构建跨工具链的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了最后三周的时间研究Mac OS X下的交叉开发.我想获得两个单独的结果,但是我相信可以通过相同的途径来达到. 我想

I spent the last three weeks researching about crossdevelopment under Mac OS X. I want to achieve two separate results, but I believe they can be reached through the same path. I want to

  1. 设置distcc,以使用我最近在家中使用的iMac(OS X 10.6,64位本机)帮助我的旧Gentoo笔记本电脑,我也将其用于iOS开发,因此Xcode 4工具已经存在;
  2. 开发我的pet项目,它是x86,x86_64和arm的精灵内核(我将在这里停下来,因为它是OT).

因此,在这些情况下我们都做了很多思考之后,我想到要实现第一个目标,我需要建立一个i686-pc-linux-gnu工具链(或者是i686- unknown-linux-gnu?)和所有适当的版本(例如gcc-4.4),并使其可由distcc调用.这似乎是一项合理的任务,但不幸的是,似乎有更清晰的工具和说明来为诸如sparc或mips之类的晦涩的弓形构建工具链,而没有一个关于如何以最佳方式获得x86的合理更新资源.因此,第一个问题是:是否有人成功地构建了这样的工具链,并且感觉像在分担痛苦? :)

So, after a lot of that thinking thing we all do in these cases, I came up the idea that to reach the first goal I need to set up an i686-pc-linux-gnu toolchain (or is it i686-unknown-linux-gnu?) with all the appropriate versions (eg gcc-4.4) and make it callable by distcc. It seems like a reasonable task, but unfortunately there seem to be clearer tools and instructions to build toolchains for obscure archs like sparc or mips, and not a single reasonably updated resource on how to go for x86 the best way. Therefore, first question: is there anybody that succesfully build such a toolchain and feels like sharing the pain? :)

第二个目标.我当前的工作台是由i686笔记本电脑上的Gentoo制成的(是的,与第一个目标相同),带有所有常规的开发资料,并且我使用QEMU对其进行了测试(它的gdb集成很棒).我真正想做的是在旅途中继续使用笔记本电脑(我经常上下班),并在回家时继续在iMac上工作和测试(git在这方面很棒).因此,第二个问题是:有没有做过这样的事情并且想分享的人?

Second goal. My current workbench is made of Gentoo on an i686 laptop (yes, the same as the first goal) with all the regular development stuff, and I use QEMU to test it (its gdb integration is awesome). What I'd really like to do is to keep using the laptop while travelling (I do a lot of commuting) and continue to work and test on the iMac when I'm home (git is awesome in this respect). Hence, second question: is there anybody that have done something like this and wants to share?

我非常感谢您的投入.认真地.

I'd really appreciate any input. Seriously.

编辑我了解MacPorts,crosstool和crosstool-ng.我尝试从MacPorts安装i386-elf-binutils 2.18,只是发现我的笔记本电脑中有2.20.另外,我无法让gcc44生成i686-pc-linux-gnu精灵对象,使用i386-elf-gcc并不是一种选择,因为我需要4.4,而打包的是4.3.

EDIT I know about MacPorts, crosstool, and crosstool-ng. I tried installing i386-elf-binutils 2.18 from MacPorts just to discover I have 2.20 in my laptop. Also I couldn't get gcc44 to produce i686-pc-linux-gnu elf objects, and using i386-elf-gcc is not an option as I need 4.4 and the packaged one is 4.3.

推荐答案

这不是一件容易的事,特别是因为您希望针对许多不同平台进行交叉编译.

This is no easy task, specially because you want to cross compile for so many different platforms.

最常用的方法是运行具有所需操作系统的虚拟机(例如平行

The most used approach is to run a Virtual Machine with the desired OS (e.g. VirtualBox, Parallels, VMWare Fusion) and install your workbench tools to work from it. This is very often used because it's not complex to setup and it also make it easier to write, test and debug code for/from the target system.

当然,如果您进行了足够的搜索,您会发现各种各样的技巧/窍门,可以在Mac OS X上设置工具链并为其他架构编译代码:

Of course, if you search enough you'll find all sorts of hacks/tricks to setup a toolchain on Mac OS X and compile code for other architectures:

  • One of these uses Buildroot, but that means that there is no official support for Mac OS X.

另一个有趣的是,它提供了 .dmg 软件包,其中包含

Another one, also interesting, offers a .dmg package with the tools needed to compile for Linux on MacOS X.

这篇关于在Mac OS X上构建跨工具链的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆