Legoless / OpenCV-Dynamic

OpenCV iOS Dynamic Framework Podspec
http://opencv.org
Other
24 stars 13 forks source link

Cannot build Pod => `Undefined symbols for architecture armv7` #4

Closed HEYGUL closed 7 years ago

HEYGUL commented 7 years ago

Trying to add opencv to my application, I declared the pod in my Podfile:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'PlateScanner' do
  use_frameworks!

  # Pods for PlateScanner
  pod 'GPUImage'
  pod 'TesseractOCRiOS', '4.0.0'
  pod 'OpenCV-Dynamic', '~> 3.x'
  pod 'Dotzu'
end

Unfortunately, it ends failing with these warnings:

ld: warning: directory not found for option '-L/usr/local/Cellar/libgphoto2/2.5.12/lib/Release-iphoneos' ld: warning: ignoring file /usr/local/Cellar/libgphoto2/2.5.12/lib/libgphoto2.dylib, missing required architecture armv7 in file /usr/local/Cellar/libgphoto2/2.5.12/lib/libgphoto2.dylib (2 slices) ld: warning: ignoring file /usr/local/Cellar/libgphoto2/2.5.12/lib/libgphoto2_port.dylib, missing required architecture armv7 in file /usr/local/Cellar/libgphoto2/2.5.12/lib/libgphoto2_port.dylib (2 slices)

Followed by linking issues:

Undefined symbols for architecture armv7: "_gp_result_as_string", referenced from: cv::gphoto2::GPhoto2Exception::what() const in cap_gphoto2.o "_gp_widget_get_label", referenced from: cv::gphoto2::DigitalCameraCapture::widgetDescription(std::1::basic_ostream<char, std::__1::char_traits >&, _CameraWidget*) const in cap_gphoto2.o "_gp_widget_get_info", referenced from: cv::gphoto2::DigitalCameraCapture::widgetDescription(std::1::basic_ostream<char, std::1::char_traits >&, _CameraWidget*) const in cap_gphoto2.o "_gp_widget_get_readonly", referenced from: cv::gphoto2::DigitalCameraCapture::widgetDescription(std::__1::basic_ostream<char, std::1::char_traits >&, _CameraWidget*) const in cap_gphoto2.o

Any idea on how to make it successful.

Legoless commented 7 years ago

The issue seems to be with gPhoto2 library, which you have installed, but I don't, because it is not used on iOS - iOS uses AVFoundation framework under the hood to access camera. Now, I am not sure why, but seems that cmake picks this setting when building the framework and attempts to link to it. The library you have installed has no armv7 (probably no armv7s or arm64) architecture, so linking fails. One solution would be to ensure that libgphoto2.dylib library you have installed also contains architectures for iOS (armv7 and arm64). The other to somehow ensure cmake does not read this setting when building for iOS.

HEYGUL commented 7 years ago

Thank you for your quick reply, I will check why cmake wants to include libgphoto2.

HEYGUL commented 7 years ago

I removed libgphoto2 and now it is working :-]