将静态库附加到 iphone/ipad 应用程序

发布于 2024-09-04 16:20:30 字数 449 浏览 4 评论 0原文

将静态库包含到 iPhone 或 iPad 应用程序中的最佳方法是什么?

我可以选择

  • 编译提供正确平台的库并使用 ar 实用程序构建库文件,然后将其作为框架添加到项目中,
  • 包括库 .c/.h 的源代码并将它们一起编译 第一种方法

似乎更简单,因为我不关心管理我想要包含的库的所有特定设置,但如何为 iPhone 和 iPad 创建库并允许 xcode 在链接时使用正确的库?

第二种方法似乎更复杂,因为 xcode 将负责编译我的应用程序和库(我想具有不同的设置)那么我应该怎么做?我可以轻松添加库的源代码,但我必须包含 make 脚本以允许 xcode 使用它们以正确的方式构建。

关于如何继续的任何建议?我试图包含的库是libssh。 (当然,我知道这个库已经在iPhone上成功编译并尝试过)

提前致谢。

which is the best approach to include a static library with into an application for iPhone or iPad?

I could choose to

  • compile the library supplying right platform and building a library file with the ar utility and then add as a framework to the project
  • including the source of the library .c/.h and compile them together with the application

The first approach seems simpler, because I won't care about managing all specific settings of the library I want to include but how can I create the library both for iPhone and iPad and allow xcode to use the right library upon linking?

The second approach seems more complex since xcode will take care about compiling my application and the library (with different settings I suppose) then how should I go? I can easily add sources of the lib but I'll have to include the make scripts to allow xcode use them to build in the right way.

Any suggestions about how to proceed? The library I'm trying to include is libssh. (I know that this library, of course, has already been compiled and tried succesfully on iPhone)

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

不必你懂 2024-09-11 16:20:31

我会采用第一种方法。

您可能应该构建两个不同版本的库,一种用于 iPhone,一种用于 iPad。这些必须是包含不同架构的胖库(iPhone 3G 的armv6、iPhone 3GS 的armv7 和第一个iPhone 模拟器的i386,另一个用于iPad 的armv7 和i386)。

基本上,您为 iPhone 构建三个不同的版本,然后使用 lipo 工具将它们合并到一个 fat 文件中。

然后,您再次为 iPad 构建两个不同的版本,并使用 lipo 将它们合并在一起。请注意,您不能在 iPad 上重复使用最初为 iPhone 编译的 armv7 和 i386 版本,因为您需要使用属于两个不同 SDK 的编译器(iPhone 为 3.1,iPad 为 3.2)来构建它们。

我不确定 lipo 是否允许您将两个 armv7 或两个 i386 版本的库合并到一个文件中而不会抱怨。您可能想尝试一下,因为在这种情况下,您可以在整个过程结束时只得到一个胖库。

I would go for the first approach.

You should probably build two different versions of your library, one for the iPhone and one for the iPad. These have to be fat libraries containing different architectures (armv6 for iPhone 3G, armv7 for iPhone 3GS, and i386 for the iPhone simulator the first, armv7 and i386 the other one for the iPad).

Basically you build three different versions for the iPhone, then merge them together in a fat file using the lipo tool.

Then, you build again two different versions for the iPad and merge them together using lipo. Note that you can not reuse for the iPad the armv7 and i386 version you compiled originally for the iPhone, because you need to build them using compilers belonging two different SDKs (3.1 for the iPhone, 3.2 for the iPad).

I am not sure if lipo will allow you to merge into a single file two armv7 or two i386 versions of the library without complaining. You may want to try this, because in this case you can come up with just one fat library at the end of the whole process.

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