错误未定义的符号:“_compress”与图像上载类

时间:2010-02-14 00:43:55

标签: iphone objective-c xcode

我想使用此类How can I upload a photo to a server with the iPhone?将图像从我的iPhone应用程序上传到我的网络服务器。

Ive Copyd标题和主文件,并将“#import”EPUploader.m“”添加到我的ViewControler中,我调用了EPUploader方法。

错误消息是:

Ld build/Release-iphonesimulator/PhotoApp.app/PhotoApp normal i386
cd /Users/phil/PhotoApp
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -L/Users/phil/PhotoApp/build/Release-iphonesimulator -F/Users/phil/PhotoApp/build/Release-iphonesimulator -filelist /Users/phil/PhotoApp/build/NaoUp.build/Release-iphonesimulator/PhotoApp.build/Objects-normal/i386/PhotoApp.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/phil/PhotoApp/build/Release-iphonesimulator/PhotoApp.app/PhotoApp

Undefined symbols:
  "_compress", referenced from:
      -[EPUploader(Private) compress:] in EPUploader.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

很抱歉,如果它是一个noobie问题..我对此新:)

2 个答案:

答案 0 :(得分:6)

您应该在项目中添加libz.dylib框架。

答案 1 :(得分:1)

您链接的问题会显示compress:方法的评论(为简洁而编辑):

* -[Uploader(Private) compress:] --
*      Uses zlib to compress the given data.

在方法内部,调用compress()

int error = compress([destData mutableBytes],
                     &destSize,
                     [data bytes],
                     [data length]);

我认为您没有将zlib与您的应用程序相关联,因此链接器无法弄清楚如何调用compress()zlib homepage具有将库与您的应用集成所需的一切。

另外 - 做#import "EPUploader.m"有点奇怪。通常,您只会#import一个头文件。