My first post in this blog was about building OpenCV for iOS devices (iPhone, iPad, iPod and so on). But the build process that i used is not trivial at all. I received a lot of feedbacks and questions about building OpenCV, setting up XCode build environment. Today i made your life much easier. I have a gift - a build script, which will build OpenCV library for your iPhone, iPad, iPod or any other iOS based Apple device right in one click! Update: Now build script supports XCode 4 and iOS 4.3 SDK Sounds cool, yeah? Well, It’s all true. Actually, my script does exactly the same things as i mentioned in original article. But without user interaction.

This post is outdated.

Current version of OpenCV supports iOS toolchain and can be build in much easier way. You are welcome to read this post for educational purposes. It’s 99.9% chance that you will not be able to build OpenCV using instructions decribed here.

Let’s build it!

We start, as usual, from getting a fresh source code from OpenCV repository:

svn co http://code.opencv.org/svn/opencv/trunk

Or, if you already have checked out in the past, run svn update command:

svn update

To start build process you should call build script with two required arguments: directory, where OpenCV sources located and directory, where libraries and headers will be places:

sh BuildOpenCV.sh trunk/opencv/ opencv_ios_build

Hit Enter and take a rest - it will take 5-10 minutes. There will be compilation errors. Something like:

It’s okay. For now, OpenCV has to official iOS support, so some parts of code will cause compilation errors (highgui module). Maybe in future this will change, but ignore them now. If you are getting other errors, it looks like either you doing something wrong, or repository build is broken. When all is done, your build directory should looks like this: