Mac OS X 上的 Linux 交叉编译器?
我在互联网上阅读了大量有关在 mac os x 上为 linux 创建交叉编译器的文档,但无法让任何文档工作。
似乎没有人能帮助我解决这个问题:获取GMP 与 GCC 4.5.2 一起工作
有没有更简单的方法来创建交叉编译器?
I've been reading lots of documents on the internet about creating a cross compiler for linux on mac os x but can't seam to get any to work.
It seams as if no one can help me with the question: Getting GMP to work with GCC 4.5.2
Is there any easy'er way to create a cross compiler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要:
4.1 brew install crosstool-ng mpfr gmp grep
4.2 brew tap homebrew/dupes
6.1 生成基本配置(对我来说这是一个arm cortex a8)
6.1.1 ct-ng arm-cortex_a8-linux-gnueabi
6.2 使用menuconfig (ct-ng menuconfig) 调整配置
6.2.1.禁用 fortran 和 java(c 编译器)
6.2.2.关闭静态链接(c 编译器)
6.2.3.将路径更改为您在上面创建的卷上(路径和杂项选项)
6.2.4.删除 dmalloc(调试工具)
6.3 调用构建:
6.3.1 ulimit -n 1024
6.3.2 ct-ng 构建
,非常感谢 crosstools-ng 列表。
You need to:
4.1 brew install crosstool-ng mpfr gmp grep
4.2 brew tap homebrew/dupes
6.1 generate a base configuration (for me this is an arm cortex a8)
6.1.1 ct-ng arm-cortex_a8-linux-gnueabi
6.2 use menuconfig (ct-ng menuconfig) to tweak the configuration
6.2.1. disable fortran and java (c compiler)
6.2.2. turn off static linking (c compiler)
6.2.3. change the paths to be on the volume you created above (paths and misc options)
6.2.4. remove dmalloc (debug facilities)
6.3 invoke the build:
6.3.1 ulimit -n 1024
6.3.2 ct-ng build
with much thanks to the crosstools-ng list.
为了为与构建主机不同的体系结构构建二进制文件,您需要的不仅仅是一个交叉编译器 - 您需要一个成熟的工具链,正如您可能发现的那样,创建这可能是一个真正的痛苦。
有几种方法:
在虚拟机中使用适当的 Linux 发行版,例如 VirtualBox。如果您只想在 MacOSX/x86_64 主机上为 Linux/i386 构建二进制文件,那么在我看来,这是最简单、最安全和最干净的解决方案。当然,它不是交叉编译器,但它可以工作,并且还有一个额外的优点,即您可以实际测试可执行文件。
使用这样的脚本
crosstool-NG
(原始的crosstool
)自动构建工具链 - 绝对比构建它更容易您自己的编译器版本,尽管您可能必须妥协于稍旧的编译器版本。In order to build binaries for architectures different that your build host, you need far more than just a cross-compiler - you need a full-blown toolchain, which can be a real pain to create, as you probably discovered.
A couple of approaches:
Use a proper Linux distribution in a virtual machine, such as VirtualBox. If you only want to build binaries for Linux/i386 on an MacOSX/x86_64 host, this is - in my opinion - the easiest, safest and most clean solution. It is not a cross-compiler, of course, but it works and it has the added advantage that you can actually test your executables.
Use a script such
crosstool-NG
(a descendant of the originalcrosstool
) to automatically build the toolchain - definitely easier than building it on your own, although you may have to compromise for slightly older compiler versions.