如何在我的 iPhone 应用程序中包含开源库?
我找到了一个现有的开源库,我想将其包含在我的 iPhone 项目中(此处找到的 unrar 源代码:
我已在 Mac 上使用“make lib”将此源代码编译为链接库,这可以很好地创建 libunrar.so 文件。
这些是该目标的 makefile 设置:
lib: WHAT=RARDLL
lib: $(OBJECTS) $(LIB_OBJ)
@rm -f libunrar.so
$(LINK) -shared -o libunrar.so $(LDFLAGS) $(OBJECTS) $(LIB_OBJ)
显然我不能在 iPhone 上使用它,但我想我应该能够使用不同的选项进行编译,以制作一个我可以使用的静态库。
我是否:
- 使用不同的 make 选项在 Mac 上编译它,然后将生成的库(某种 .a ?)拖到我的 xcode 项目中? 或者
- 将所有源代码拖到我的 xcode 项目中并创建某种特殊目标来创建它? 或者
- 其他完全不同的东西?
我已经花了几周的时间来解决我的 unrar 问题,我相信使用这个库会给我最好的结果,但我只是不知道使用它的最后步骤。
感谢您的所有建议。
I have found an existing open source library that I would like to include in my iPhone project (the unrar source code found here: http://www.rarlab.com/rar_add.htm ).
I have compiled this source as a linked library on my Mac with "make lib" which creates the libunrar.so file just fine.
These are the makefile settings for that target:
lib: WHAT=RARDLL
lib: $(OBJECTS) $(LIB_OBJ)
@rm -f libunrar.so
$(LINK) -shared -o libunrar.so $(LDFLAGS) $(OBJECTS) $(LIB_OBJ)
Obviously I can't use this on iPhone but I imagine I should be able to compile with different options to make a static library that I can use.
Do I:
- Compile it on the Mac with different make options then drag the resulting library (some kind of .a ?) into my xcode project?
or - Drag all of the source code into my xcode project and create special targets of some kind to create it?
or - Something else entirely different?
I've been working on solving my unrar problem for a couple of weeks now and I believe using this library will give me the best results but I just don't know the final steps to make use of it.
Thanks for all advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可能会首先想做最简单的事情,创建一个空的 iPhone 项目并将所有代码放入其中,只是为了看看它是否可以编译。
如果是这样,您可能希望使用空项目来帮助开发 Objective-C 包装器,完成后您可以将代码引入现有项目中进行集成和测试。
如果您希望将此代码用于其他项目,或者您愿意提供该代码的 iPhone 移植版,请继续将其合并到一个库中。
这是一个记录该过程的网站。
I think that you'll probably want to do the easiest thing first, create an empty iPhone project and bring all of the code into it, just to see if it will compile.
If so, you may want to use the empty project to aid in the development of an Objective-C wrapper, once that is complete you can bring the code into your existing project for integration and testing.
If it looks like this is code that you would like to use with other projects, or you are feeling giving and would like to provide an iPhone port of the code, go ahead and pull this together into a library.
Here is a site that documents the process.