Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking problem in Xcode when using a dependent subproject

I am using Xcode to write an iPhone project and I use an external library. I added the Xcode project file to the parent target and adjusted the header search path and set it as a direct dependency in the parent's build target.

Now the strange thing happens: I can open the library and compile it without problems. The library links to some frameworks e.g. AVFoundation.framework.

I clean the target and start building the parent project. In my build results I see that it builds the library, but then the linking fails with these error messages:

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

I can include the needed frameworks in the parent project, but I thought that by including the frameworks in the library project the linking would be OK.

My question is: Do I have to include all the frameworks that my dependent subprojects use in the parent project to ensure proper linking, or am I doing something wrong?

Thanks for your help.

like image 299
GorillaPatch Avatar asked Dec 16 '22 17:12

GorillaPatch


1 Answers

make sure include "CoreMedia.framework","AudioToolbox.framework","CoreGraphics.framework","CoreVideo.framework","AVFoundation.framework","libiconv.dylib" frameworks in project in Build Phases

like image 192
wormlxd Avatar answered Dec 19 '22 08:12

wormlxd