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/insite.app/insite
Expected in: /usr/lib/libobjc.A.dylib
dyld: Symbol not found: _objc_setProperty_nonatomic
Referenced from: /var/mobile/Applications/9C52EB2F-9A11-4656-BBAC-0EE6960A323B/insite.app/insite
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 ./build_framework.py /Users/praveencastelino/Downloads/ 5.0


1] go to the iOS folder in the OpenCV source.
2] Excecute the python script python ./build_framework.py <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.

Advertisements

Building OGRE for iOS

I was looking out for a 3D Engine (OpenSource) to render 3D models. I wanted to use Cocos3d but this has few limitations. It is not a cross platform engine. [ I can’t ignore my friend Android 😦 ]. Also, it lacks many of the cool features when compared to sophisticated 3D engines. The next engine was OGRE. This is written C++ and a cross platform engine. Moreover, this is exactly what I was looking for. After downloading the source, the next big task was to compile the source. There are many tutorials available in the website but most them are obsolete. So I thought of writing one myself to help someone to quickly get started with OGRE 🙂

Follow the following steps to compile OGRE on iOS platform:

  • Get the latest source from here(v1.8.1)
  • Download the OGRE iOS dependancy and XCode template from here(1.8)
  • Open the iOS dependancies dmg and copy the folder iOSDependencies to the source folder ogre_src_v1-8-1. Ensure that the iOSDependencies and OgreMain folder are at the same hierarchical level.
  • OGRE folder structure
  • Now, navigate to the SDK -> iOS folder. You should find a make_ios.sh script.iOS script
  • Open the terminal and navigate it to the above folder where the script resides and run the script ./make_ios.sh in the terminal.
  • If everything worked fine then you should see a build folder in the same location where the script was. This folder contains a XCode project. XCode Build folder
  • Launch the  XCode project and set the target to SampleBrowser. Run the project. Wait for the Simulator to launch the OGRE beast 🙂XCode OGRE Project

PS: XCode Version 4.6.1 (4H512) and OS X (10.8.3)