在 Mac 上交叉编译 iPhone?
我该如何设置所有内容,以便从我的 OSX 10.7 Macbook pro 到我越狱的第 4 代 iPod touch 进行交叉编译。我的主要目标是能够将开源库移植到 iPhone 上。我似乎找不到任何关于 iOS 4 交叉编译的好/最近的文章。
How would I go about setting everything up to cross compile from my OSX 10.7 Macbook pro to my jailbroken 4th generation iPod touch. I'm mainly aiming to be able to port open source libraries to iphone. I can't seem to find any good/recent articles on cross compiling for iOS 4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过一番尝试,我发现可以使用
./configure
并强制它为arm-apple-darwin11构建。您必须在./configure --some-flags
之后直接使用这些标志:CPP 和 CXXCPP 是所需的预处理器(默认); CC 和 CXX 是 Xcode 附带的用于 arm 的 c 和 c++ 编译器的路径,其他是编译器获取的标志或定义编译时使用的最常用工具的路径的宏。我不能保证一切都会奏效,但这是你应该做的一个好主意。
我建议向
./configure
添加这些标志:它们的作用是帮助创建一个 makefile,该文件将在
/tmp/build
下的文件夹中发送库和程序。After some attempt, I found out that it's possible to use
./configure
and force it to build for arm-apple-darwin11. You have to use these flags directly after the./configure --some-flags
:CPP and CXXCPP are the preprocessor required (the default one); CC and CXX are the path to the c and c++ compiler for arm that comes with Xcode, the other are flags the compiler gets or macros that defines the path to the most common tools used when compiling. I cannot grant everything will work, but this is a good idea of what you should do.
I'd suggest to add to
./configure
these flags:what they do is to help create a makefile that will send libs and programs in a folder under
/tmp/build
.我也没有。我尝试的所有工具链最终都无法工作或创建 x86_64 二进制文件,这在 iOS 上无法工作。
我目前正在尝试直接在我的 iPad 上构建 apr,因为我已经从 Cydia 安装了所有必需的东西,但我陷入了 kqueue.c 无法正确编译的困境。我已经移植了lua和其他一些软件,所以我可以说它通常是这样工作的。在本机平台上构建而不是交叉编译的主要原因是某些程序依赖于其他程序(例如:apr 上的 apr-util),因此其中一些程序必须运行。但是,不可能在 intel 上运行 arm(至少没有仿真,并且 iPhone Simulator 使用 i386 二进制文件)。
任何对在 iOS 上使用/构建 UNIX 工具感兴趣的人都必须记住以下几点:
另外,您可能必须对您构建的任何软件进行(伪造)代码签名。
所以,要小心并做好准备,因为事情通常并不容易。
关于 Mac 没有工具链(Apple 提供的工具链除外)的事实,这可能可以解释,因为您不需要 Mac 来下载 Xcode,而 Mac 的成本通常高于开发人员愿意花的钱。这意味着尽管 Mac 硬件最近蓬勃发展,但没有多少人在做与您相同的事情。已经或多或少成功地为基于 Linux 的操作系统(例如 Ubuntu)构建了工具链。您始终可以尝试使用虚拟机。
Neither did I. All the toolchain I tried ended up in not working or creating x86_64 binaries, which won't work on iOS.
I'm currently trying to build apr directly on my iPad as I have installed from Cydia all the required things, yet I'm stuck kqueue.c not compiling properly. I have already ported lua and some other software, so I can say it generally works this way. The main reason for building on a native platform rather than cross compiling is that some programs rely on other programs (example: apr-util on apr) so some of them must be run. However, it's not possible to run arm on intel (at least without emulation, and iPhone Simulator uses i386 binaries).
Anyone who's interested in using/building UNIX tools on iOS has to keep these points in mind:
Plus you'll probably have to (fake)code sign any software you build.
So, beware and brace yourself, because things are not easy usually.
About the fact of Mac being without a toolchain (except the one provided by Apple), this may hold an explanation as you don't need to have a mac to download Xcode, while a mac cost usually more than devs are willing to spend. This means there aren't much people doing the same thing you do, despite the boom mac hardware has had recently. Toolchains have been more or less successfully built for Linux based OSes, such as Ubuntu. You can always try to use a VM.