Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV for iOS - Linking Libraries in Xcode

Hi,

as part of a team project I intend to implement obstacle detection for a robot using open cv. I am now at a point where I have functional code that runs on OS X and uses my laptop camera to detect obstacles approaching it. However the robot runs iOS (it is an iPad at heart) and thus requires me to build for iOS. Obviously the linker now doesn't accept the OS X library files, because of architecture mismatches. So far it is set up as follows:
1. /usr/local/lib added to Library Search Paths
2. /usr/local/include added to Header Search Paths
3. c++ language dialect changed to C++11
4. Libraries added to Other Linker Flags ( -lopencv_calib3d etc.)
5. Valid Architectures set to i386,x86_64

In order to perform the necessary modifications for iOS I first of all changed the valid architectures to armv7, armv7s, and arm64. Then I attempted to follow the instructions on OpenCV:Installation in iOS, asking me to execute the opencv/platforms/ios/build_framework.py script. This built a framework file which I added to my Xcode project via Build Phases -> Link Binary With Libraries. According to the python script's readme "The script builds OpenCV.framework for iOS. The built framework is universal, it can be used to build app and run it on either iOS simulator or real device." However when I try to build the product for iOS simulator (amongst others), I get uncountable Undefined symbols for architecture x86_64 linker errors. As far as I am aware there is nothing else to the installation instructions linked above though.

Am I missing something here? Adjusting header/library search paths to include either nothing or the OS X OpenCV library files from /usr/local/lib was to no avail. My intuition is that is has something to do with the folder build inside of the folder that contains the opencv2.framework file. The contents of build are the folders:
iPhoneOS-arm64
iPhoneOS-armv7
iPhoneOS-armv7s
iPhoneSimulator-i386
iPhoneSimulator-x86_64

These in turn are comprised of:
iPhoneOS-arm64 contents

Do I need to link any part of these folders into my project?

I am grateful for any advice.

Warm regards,
Mark