Compiling OpenCV source to support iOS 5.0

The latest version of the OpenCV framework isn’t compatible with anything other than iOS 6.0. This is due to the script what they used to build the framework. Since they have not specified the deployment target, the XCode takes iOS 6.0 (the latest SDK) as the default deployment target. This is very annoying as there are many users who still use iOS 5.0.

The latest OpenCV framework[v2.4.5] for iOS can be downloaded from here. If you try to build the application using this framework and try to run the compiled app on iOS 5, you will encounter this error.

dyld: lazy symbol binding failed: Symbol not found: _objc_setProperty_nonatomic
Referenced from: /var/mobile/Applications/9C52EB2F-9A11-4656-BBAC-0EE6960A323B/
Expected in: /usr/lib/libobjc.A.dylib
dyld: Symbol not found: _objc_setProperty_nonatomic
Referenced from: /var/mobile/Applications/9C52EB2F-9A11-4656-BBAC-0EE6960A323B/
Expected in: /usr/lib/libobjc.A.dylib

After googling, I ended up with this link where they have addressed the problem as well as the fix for the problem. I had to download the entire OpenCV source from github.Though this wasn’t the latest code [v2.4.3], I still downloaded the source as this had deployment target correction script.

After you download the source, you need to execute the following 2 commands in the terminal.

cd /Users/praveencastelino/Downloads/opencv-ios_deployment_target_722dedb/ios
python ./ /Users/praveencastelino/Downloads/ 5.0

1] go to the iOS folder in the OpenCV source.
2] Excecute the python script python ./ <build directory> <deployment target>

If everything works fine then you should have the OpenCV framework compiled to run on iOS 5.0.
OpenCV build folder structure

You can also download the OpenCV framework that I have compiled from here.