在 XCode 4 项目中编译 ZipArchive

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5645269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:49:01  来源:igfitidea点击:

Compiling ZipArchive in XCode 4 project

iphonexcodecompressionzipxcode4

提问by jakev

I'm trying to compile ZipArchive with my project. I imported all the source files, including the minizip files and I am at a loss to understand these errors. I've tried a dozen other ways to incorporate compression/decompression into my iphone project, all with out success. ZipArchive seems to be the best library out, and this problem looks like it's a simple build settings configuration problem but I cannot figure it out.

我正在尝试用我的项目编译 ZipArchive。我导入了所有源文件,包括 minizip 文件,但我无法理解这些错误。我已经尝试了十几种其他方法将压缩/解压缩合并到我的 iphone 项目中,但都没有成功。ZipArchive 似乎是最好的库,这个问题看起来像是一个简单的构建设置配置问题,但我无法弄清楚。

Undefined symbols for architecture armv6:
  "_zipClose", referenced from:
      -[ZipArchive CloseZipFile2] in ZipArchive.o
  "_zipOpenNewFileInZip3", referenced from:
      -[ZipArchive addFileToZip:newname:] in ZipArchive.o
  "_unzOpenCurrentFile", referenced from:
      -[ZipArchive UnzipFileTo:overWrite:] in ZipArchive.o
  "_unzGetGlobalInfo", referenced from:
      -[ZipArchive UnzipOpenFile:] in ZipArchive.o
  "_unzReadCurrentFile", referenced from:
      -[ZipArchive UnzipFileTo:overWrite:] in ZipArchive.o
  "_unzOpen", referenced from:
      -[ZipArchive UnzipOpenFile:] in ZipArchive.o
  "_unzCloseCurrentFile", referenced from:
      -[ZipArchive UnzipFileTo:overWrite:] in ZipArchive.o
  "_zipWriteInFileInZip", referenced from:
      -[ZipArchive addFileToZip:newname:] in ZipArchive.o
  "_zipOpenNewFileInZip", referenced from:
      -[ZipArchive addFileToZip:newname:] in ZipArchive.o
  "_unzGoToFirstFile", referenced from:
      -[ZipArchive UnzipFileTo:overWrite:] in ZipArchive.o
  "_unzGetCurrentFileInfo", referenced from:
      -[ZipArchive UnzipFileTo:overWrite:] in ZipArchive.o
  "_zipCloseFileInZip", referenced from:
      -[ZipArchive addFileToZip:newname:] in ZipArchive.o
  "_unzClose", referenced from:
      -[ZipArchive UnzipCloseFile] in ZipArchive.o
  "_zipOpen", referenced from:
      -[ZipArchive CreateZipFile2:] in ZipArchive.o
  "_unzGoToNextFile", referenced from:
      -[ZipArchive UnzipFileTo:overWrite:] in ZipArchive.o
  "_unzOpenCurrentFilePassword", referenced from:
      -[ZipArchive UnzipFileTo:overWrite:] in ZipArchive.o
ld: symbol(s) not found for architecture armv6
collect2: ld returned 1 exit status

回答by Dominic Sander

I had exactly the same issue. I use Xcode 4.4 for iOS 5.1. And I solved it this way:

我有完全相同的问题。我将 Xcode 4.4 用于 iOS 5.1。我是这样解决的:

  1. Remove the all ZipArchive-Files incl. Minizip-Folder from your project - move to trash.
  2. Re-Add both ZipArchive-Files and the Minitip-Folder and ENSURE YOU SELECT THE OPTION "Create groups for any added folder" instead of "Create folder references for any added folder".
  3. if you use ARC, then add to all Build Phases -> Compile Sources ZipArchive-Items the option "-fno-objc-arc"
  1. 删除所有 ZipArchive-Files incl。项目中的 Minizip 文件夹 - 移至垃圾箱。
  2. 重新添加 ZipArchive-Files 和 Minitip-Folder 并确保您选择选项“为任何添加的文件夹创建组”而不是“为任何添加的文件夹创建文件夹引用”。
  3. 如果您使用 ARC,则将选项“-fno-objc-arc”添加到所有 Build Phases -> Compile Sources ZipArchive-Items

That′s it - good luck.

就是这样 - 祝你好运。

回答by Divyang Mithaiwala

When I tried it will easily compiled with following link

当我尝试时,它会通过以下链接轻松编译

http://code.google.com/p/ziparchive/wiki/PageName

http://code.google.com/p/ziparchive/wiki/PageName

I just take folder in following Form

我只是在以下表格中取文件夹

ZipArchive 
   ZipArchive.h
   ZipArchive.mm
   minizip (Folder)

Then just drag & drop ZipArchive folder in to xCode "Classes".

然后只需将 ZipArchive 文件夹拖放到 xCode“类”中。

Then add framework libz.1.2.3.dylib.

然后添加框架libz.1.2.3.dylib。

That's it. My code get compile without any issue.

就是这样。我的代码可以毫无问题地编译。

回答by sixFingers

I got it working by adding "/usr/lib/libz.dylib" to the Other Link Flags in the targets section of Project settings.

我通过将“/usr/lib/libz.dylib”添加到项目设置的目标部分中的其他链接标志来使其工作。

It worked for me with Minizip.

Minizip 对我有用。

回答by Shunsuke Ichikawa

I also fell into this same case....

我也陷入了同样的情况......

But I found the following resolution.

但我找到了以下解决方案。

http://travitu.hatenablog.jp/entry/2014/12/23/005037

http://travitu.hatenablog.jp/entry/2014/12/23/005037

I solved it this way:

我是这样解决的:

?When you add ZipArchive-Files and the Minitip-Folder to your project, you should check "Copy items if needed" and "Create groups".

?当您将 ZipArchive-Files 和 Minitip-Folder 添加到您的项目时,您应该选中“如果需要复制项目”和“创建组”。

That's all.

就这样。

回答by Philip Borges

I got this working by adding libz.tdb file. (Xcode 7, iOS 9). Error gone.

我通过添加 libz.tdb 文件得到了这个工作。(Xcode 7,iOS 9)。错误消失。