简体   繁体   English

如何为Xcode项目和iOS应用程序制作libtiff?

[英]How to make libtiff for an Xcode project and an iOS application?

I have been searching up and down stackoverflow and Google for the correct way to compile and add the libtiff library to my existing iOS project in Xcode. 我一直在stackoverflow和Google上下搜索,寻找正确的方法来编译libtiff库并将其添加到Xcode中现有的iOS项目中。

What I have done so far: 到目前为止,我所做的是:

EDIT: 编辑:

I have downloaded libtiff to my Mac after deciding to follow this advice on stackoverflow . 在决定遵循有关stackoverflow的建议后,我已将libtiff下载到我的Mac。 I used version 3.9.6 and built it like in this tutorial and its sequel about SDK5. 我使用了3.9.6版,并像本教程及其关于SDK5的续集一样构建了它。 There, in the comments, I found a script I could adapt . 在那里,在评论中,我找到了可以适应脚本 I have added the resulting "dependencies" folder to my Xcode project, almost like rakmoh suggested. 我已经将生成的“ dependencies”文件夹添加到我的Xcode项目中,几乎就像rakmoh建议的那样。

However, I got linker errors as soon as I #include tiffio.h : 但是,一旦我#include tiffio.h ,我就收到了链接器错误:

Undefined symbols for architecture armv7:  "_inflateEnd", referenced from:
  _PixarLogCleanup in libtiff.a(tif_pixarlog.o)
  _ZIPSetupEncode in libtiff.a(tif_zip.o)
.
... some more...
.
ld: symbol(s) not found for architecture armv7 
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I also tried the newest version of libtiff , but that did not change a thing, so I went back to 3.9.6, as it is compatible with the other softwares in the project. 我还尝试了最新版本的libtiff ,但是并没有改变任何事情,因此我回到了3.9.6,因为它与项目中的其他软件兼容。 Then I asked a colleague who found out it was the libz library missing. 然后我问一个同事,他发现那是libz库丢失了。 From the log files he saw it must have been there during the compilation of libtiff and it was still missing for the linker in my Xcode project. 从日志文件中,他看到libtiff编译期间肯定已经存在该文件,而Xcode项目中的链接器仍然缺少该文件。 And lo! 瞧! When I added it to the frameworks (with the little + sign and browse the list for libz.dylib ), my empty test project compiled. 当我将其添加到框架中时(带有小+号并浏览libz.dylib的列表),我的空测试项目已编译。

Before writing an answer, I would like to do some more testing, but I have already updated the successful shell script to pastebin . 在写答案之前,我想做一些测试,但是我已经将成功的shell脚本更新为pastebin

Thank you for your help! 谢谢您的帮助!

Here are the steps for adding a library to your iOS project in XCode 4.6.2 (should be similar in old versions of XCode): 以下是在XCode 4.6.2中将库添加到iOS项目中的步骤(在旧版本的XCode中应该类似):

  • Click on your project name in the project navigator (left pane) 在项目导航器中单击您的项目名称(左窗格)
  • Click on your Target and select "Build Phases" 单击您的目标,然后选择“构建阶段”
  • Under "Link Binary With Libraries" click "+" (at the end of the existing list) 在“将二进制文件与库链接”下,单击“ +”(在现有列表的末尾)
  • Select "Add Other.." button in the popover window, it will open the file browser window 在弹出窗口中选择“添加其他..”按钮,它将打开文件浏览器窗口
  • Browse to and select the library that you want to add and click "Open" 浏览并选择要添加的库,然后单击“打开”

I have pasted a bash script that cross-compiles libtiff version 3.9.6 on a Mac for iOS 6.1 to be used on devices and in the simulator. 我粘贴了一个bash脚本 ,该脚本在Mac上针对iOS 6.1的Mac上交叉编译libtiff版本3.9.6 ,以在设备和模拟器中使用。 You will have to adapt it to your needs. 您将不得不使其适应您的需求。 Also see this tutorial for hints. 另请参阅本教程以获取提示。 It creates a fat library for both compilation targets. 它为两个编译目标都创建了一个胖库。

rakmoh s answer is also correct, but only part of the solution. rakmoh的答案也是正确的,但这只是解决方案的一部分。 You add the folder with the fat library in the "Add Other.." dialogue he proposes. 您可以在他建议的“添加其他..”对话框中添加带有胖库的文件夹。

Then you also add libz.dylib! 然后,您还添加libz.dylib! After that, I could use libtiff in my app on my device and on the simulator. 之后,我可以在设备和模拟器上的应用程序中使用libtiff

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM