如何在 Mac OS X 上编译通用库? [英] How to compile universal libraries on Mac OS X?
问题描述
这可能是一个非常愚蠢的问题,但我是在 Mac 上开发的新手,并且很难使用通用二进制文件.
This may be a very silly question, but I'm new to developing on Macs and am having a hard time with the universal binaries.
我有一个正在 QT Creator 中编译的应用程序,据 lipo 称,它正在生成 i386 架构输出.据我了解,这意味着它正在生成 Mac OS X 32 位输出.
I've got an application that I'm compiling in QT Creator, which according to lipo is producing i386 architecture outputs. As I understand it, that means it is producing Mac OS X 32 bit outputs.
应用程序依赖于两个外部库.我正在通过首先调用 ./config 编译这些库之一,然后调用../config 声明它是为 darwin-i386-cc 配置的".但是,运行 make 并在结果上调用 lipo 后,架构报告为 x86_64.
The application depends on two external libraries. One of these libraries I'm compiling by calling ./config first, and then make. ./config states that it is "Configured for darwin-i386-cc". However, after running make, and calling lipo on the result, the architecture is reported as x86_64.
同样,我还有另一个外部库.那个没有配置脚本,我只是通过调用 make 来编译它.这个输出也是 x86_64.
Similarly, I have another external library. That one has no configure script, and I compile it simply by calling make. The output from this one too is x86_64.
我如何编译这两个外部库,以便它们生成与我的应用程序的 i386 输出兼容的内容?更好的是,我如何编译这两个外部库以生成通用库,以便我可以从我的应用程序生成一个适用于 32 位和 64 位的通用二进制文件?
此外,根据 Mac 世界的当前状态,我应该针对其他平台来创建合适的、用户友好的 Mac OS X 通用二进制文件吗?
Also, based on the current state of the Mac world, are there any other platforms that I should be expected to target to create a proper, user-friendly Mac OS X universal binary?
推荐答案
终于搞定了.
为了控制目标的架构,我手动进去编辑了Makefiles.
In order to control the architecture of the target, I manually went in and edited the Makefiles.
对于其中之一,我添加到以 CFLAGS 开头的行的末尾:-arch i386 -arch x86_64 -arch ppc这产生了一个通用的二进制文件.
For one of them, I added to the end of the line that starts with CFLAGS: -arch i386 -arch x86_64 -arch ppc This produced a universal binary.
另一方面,当我做同样的事情时,编译会出错.我不得不循环,一次只放一个拱形,然后在我制作了所有三个后,我用 -create 标志在它们上调用 lipo 以创建一个通用二进制文件.
For the other, when I did the same thing, the compile would error out. I had to cycle through and only put one arch at a time, and then after I produced all three, I called lipo on them with the -create flag to create a universal binary.
这篇关于如何在 Mac OS X 上编译通用库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!