xcode ZipArchive 库编译错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3528316/
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 19:39:07  来源:igfitidea点击:

ZipArchive library compile error

iphonexcode

提问by RAGOpoR

i have included libz.1.2.3.dylib

我已经包含了 libz.1.2.3.dylib

after insert code

插入代码后

ZipArchive* za = [[ZipArchive alloc] init];

error when compile

编译时出错

 "_OBJC_CLASS_$_ZipArchive", referenced from:

UPDATE

更新

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

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

i have include ZipArchive folder to project, and and framework libz.1.2.3.dylib.

我已经将 ZipArchive 文件夹包含到项目中,以及框架 libz.1.2.3.dylib。

then i try to unzip file on iphone but it error about framework. how to resolve it?

然后我尝试在 iphone 上解压缩文件,但它关于框架的错误。如何解决?

Ld build/ePUBreader.build/Debug-iphoneos/ePUBreader.build/Objects-normal/armv7/ePUBreader normal armv7
cd /Users/ragopor/Desktop/ePUBreader
setenv IPHONEOS_DEPLOYMENT_TARGET 4.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -L/Users/ragopor/Desktop/ePUBreader/build/Debug-iphoneos -F/Users/ragopor/Desktop/ePUBreader/build/Debug-iphoneos -filelist /Users/ragopor/Desktop/ePUBreader/build/ePUBreader.build/Debug-iphoneos/ePUBreader.build/Objects-normal/armv7/ePUBreader.LinkFileList -dead_strip -miphoneos-version-min=4.0 -framework Foundation -framework UIKit -framework CoreGraphics -framework StoreKit -lz.1.2.3 -o /Users/ragopor/Desktop/ePUBreader/build/ePUBreader.build/Debug-iphoneos/ePUBreader.build/Objects-normal/armv7/ePUBreader

Undefined symbols:
  "_OBJC_CLASS_$_ZipArchive", referenced from:
      objc-class-ref-to-ZipArchive in ePUBreaderAppDelegate.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

采纳答案by Vineel Shah

When you drag the ZipArchive folder into your project, you have to choose "Create groups for any added folders" and not "Create folder references for any added folders." If you choose the latter, you'll get the Undefined Symbol error from the linker.

当您将 ZipArchive 文件夹拖到您的项目中时,您必须选择“为任何添加的文件夹创建组”而不是“为任何添加的文件夹创建文件夹引用”。如果您选择后者,您将收到来自链接器的未定义符号错误。

回答by Karthikkumar

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 jtbandes

ZipArchive is not in libz.dylib. Where is ZipArchive supposed to come from? It's not getting compiled or linked to your app.

ZipArchive 不在 libz.dylib 中。ZipArchive 应该来自哪里?它没有被编译或链接到您的应用程序。

回答by Codo

You say you have added the ZipArchive folder to the project. From your description, it seems that the header file ZipArchive.h is found during the compilation of the project, but it does not compile the ZipArchive.mm file, which contains the ZipArchive class.

您说您已将 ZipArchive 文件夹添加到项目中。从你的描述来看,似乎是在编译项目的过程中找到了头文件ZipArchive.h,但是并没有编译出包含ZipArchive类的ZipArchive.mm文件。

The file extension .mm seems strange to me. It might be the reason the file in't compiled. Try to rename it to ZipArchive.m and try again.

文件扩展名 .mm 对我来说似乎很奇怪。这可能是文件未编译的原因。尝试将其重命名为 ZipArchive.m 并重试。

回答by Ahmad Kayyali

i have used this library before, you need to compile the library in Xcode static library then later included it in your project, see the following link it will help you a lot.

我之前使用过这个库,你需要在 Xcode 静态库中编译这个库,然后将它包含在你的项目中,请参阅以下链接,它会对你有很大帮助。

http://code.google.com/p/ziparchive/issues/detail?id=4

http://code.google.com/p/ziparchive/issues/detail?id=4