2011-02-18 48 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」 在構建階段

框架項目