I have listed some easy and straight-forward steps below to get OpenCV library working with XCode on Mac OS X Lion without installing unnecessary bulky software on your Mac.
1. Installing CMake
i. CMake is essential to build OpenCV on UNIX. Get CMake Mac OS X binary (dmg) from http://www.cmake.org/cmake/resources/software.html. This comes with a GUI installer, making the installation process easy.
ii. At the end of the CMake installation it will ask whether or not to put CMake into /usr/bin and into PATH environment variable, select Yes and finish the installation.
iii. Open the Terminal (Launch Pad -> Utilities -> Terminal) and make sure that CMake is successfully installed by entering the following command. It should output the CMake version you have installed.
2. Installing OpenCV
i. Download the latest version of OpenCV for UNIX. At the time of writing this is version 2.3.1 and can be downloaded from http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/
ii. Open the Terminal and change directory to the place where you downloaded the OpenCV distribution tarball. e.g. cd ~/Downloads
iii. Execute the following commands one by one. Each command should complete without errors.
iv. Above commands will build OpenCV into your
3. Testing a Sample Program with XCode
libopencv_core.2.3.1.dylib
#include <iostream>
1. Installing CMake
i. CMake is essential to build OpenCV on UNIX. Get CMake Mac OS X binary (dmg) from http://www.cmake.org/cmake/resources/software.html. This comes with a GUI installer, making the installation process easy.
ii. At the end of the CMake installation it will ask whether or not to put CMake into /usr/bin and into PATH environment variable, select Yes and finish the installation.
iii. Open the Terminal (Launch Pad -> Utilities -> Terminal) and make sure that CMake is successfully installed by entering the following command. It should output the CMake version you have installed.
cmake -version
2. Installing OpenCV
i. Download the latest version of OpenCV for UNIX. At the time of writing this is version 2.3.1 and can be downloaded from http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/
ii. Open the Terminal and change directory to the place where you downloaded the OpenCV distribution tarball. e.g. cd ~/Downloads
iii. Execute the following commands one by one. Each command should complete without errors.
tar xvf OpenCV-2.3.1a.tar.bz2
cd OpenCV-2.3.1
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
sudo make install
iv. Above commands will build OpenCV into your
/usr/local/
directory. 3. Testing a Sample Program with XCode