2011-02-18 49 views
4

我正在使用Xcode编写iPhone项目,并使用外部库。我将Xcode项目文件添加到父目标,并调整了头搜索路径,并将其设置为父目标构建目标中的直接依赖项。使用从属子项目时Xcode中的链接问题

现在发生了一件奇怪的事情:我可以打开库并编译它,没有问题。该库链接到一些框架,例如AVFoundation.framework

我清理目标并开始构建父项目。在我的构建结果我看到,它建立了图书馆,但随后的连接失败,这些错误信息:

Undefined symbols: 
    "_AVCaptureSessionPresetMedium", referenced from: 
     _AVCaptureSessionPresetMedium$non_lazy_ptr in libZXingWidget.a(ZXingWidgetController.o) 
    (maybe you meant: _AVCaptureSessionPresetMedium$non_lazy_ptr) 
    "_CVPixelBufferGetHeight", referenced from: 
     -[ZXingWidgetController captureOutput:didOutputSampleBuffer:fromConnection:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_CVPixelBufferLockBaseAddress", referenced from: 
     -[ZXingWidgetController captureOutput:didOutputSampleBuffer:fromConnection:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_AudioServicesPlaySystemSound", referenced from: 
     -[ZXingWidgetController presentResultForString:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_AudioServicesCreateSystemSoundID", referenced from: 
     -[ZXingWidgetController viewWillAppear:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_CVPixelBufferUnlockBaseAddress", referenced from: 
     -[ZXingWidgetController captureOutput:didOutputSampleBuffer:fromConnection:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_CVPixelBufferGetBaseAddress", referenced from: 
     -[ZXingWidgetController captureOutput:didOutputSampleBuffer:fromConnection:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_CVPixelBufferGetBytesPerRow", referenced from: 
     -[ZXingWidgetController captureOutput:didOutputSampleBuffer:fromConnection:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_iconv_close", referenced from: 
     zxing::qrcode::DecodedBitStreamParser::append(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned char const*, unsigned long, char const*)in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o) 
     zxing::qrcode::DecodedBitStreamParser::append(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned char const*, unsigned long, char const*)in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o) 
    "_OBJC_CLASS_$_AVCaptureVideoPreviewLayer", referenced from: 
     objc-class-ref-to-AVCaptureVideoPreviewLayer in libZXingWidget.a(ZXingWidgetController.o) 
    "_iconv", referenced from: 
     zxing::qrcode::DecodedBitStreamParser::append(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned char const*, unsigned long, char const*)in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o) 
    "_OBJC_CLASS_$_AVCaptureSession", referenced from: 
     objc-class-ref-to-AVCaptureSession in libZXingWidget.a(ZXingWidgetController.o) 
    "_OBJC_CLASS_$_AVCaptureDevice", referenced from: 
     objc-class-ref-to-AVCaptureDevice in libZXingWidget.a(ZXingWidgetController.o) 
    "_kCVPixelBufferPixelFormatTypeKey", referenced from: 
     _kCVPixelBufferPixelFormatTypeKey$non_lazy_ptr in libZXingWidget.a(ZXingWidgetController.o) 
    (maybe you meant: _kCVPixelBufferPixelFormatTypeKey$non_lazy_ptr) 
    "_OBJC_CLASS_$_AVCaptureVideoDataOutput", referenced from: 
     objc-class-ref-to-AVCaptureVideoDataOutput in libZXingWidget.a(ZXingWidgetController.o) 
    "_CVPixelBufferGetWidth", referenced from: 
     -[ZXingWidgetController captureOutput:didOutputSampleBuffer:fromConnection:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_AudioServicesDisposeSystemSoundID", referenced from: 
     -[ZXingWidgetController dealloc] in libZXingWidget.a(ZXingWidgetController.o) 
    "_OBJC_CLASS_$_AVCaptureDeviceInput", referenced from: 
     objc-class-ref-to-AVCaptureDeviceInput in libZXingWidget.a(ZXingWidgetController.o) 
    "_AVLayerVideoGravityResizeAspectFill", referenced from: 
     _AVLayerVideoGravityResizeAspectFill$non_lazy_ptr in libZXingWidget.a(ZXingWidgetController.o) 
    (maybe you meant: _AVLayerVideoGravityResizeAspectFill$non_lazy_ptr) 
    "_CMSampleBufferGetImageBuffer", referenced from: 
     -[ZXingWidgetController captureOutput:didOutputSampleBuffer:fromConnection:] in libZXingWidget.a(ZXingWidgetController.o) 
    "_iconv_open", referenced from: 
     zxing::qrcode::DecodedBitStreamParser::append(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned char const*, unsigned long, char const*)in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o) 
    "_AVMediaTypeVideo", referenced from: 
     _AVMediaTypeVideo$non_lazy_ptr in libZXingWidget.a(ZXingWidgetController.o) 
    (maybe you meant: _AVMediaTypeVideo$non_lazy_ptr) 
ld: symbol(s) not found 
collect2: ld returned 1 exit status 

我可以包括在父项目所需要的框架,但我认为,通过在框架库项目的链接将是确定的。

我的问题是:我是否必须包括我的从属子项目在父项目中使用的所有框架以确保正确链接,或者我是否做错了什么?

感谢您的帮助。

回答

3

如果子项目编译成静态库,是的。

+0

我正在编译成一个静态库,因为它是针对iOS的。这真的很不方便。为什么子项目中的链接不够? – GorillaPatch 2011-02-18 18:55:28

9

确保包括 “CoreMedia.framework”, “AudioToolbox.framework”, “CoreGraphics.framework”, “CoreVideo.framework”, “AVFoundation.framework”, “libiconv.dylib” 在构建阶段

框架项目