Install OpenCV 2.3.1a in Mac OS X 10.6

Download OpenCV 2.3.1a and unpack it:

curl -L -O
tar xzvpf OpenCV-2.3.1a.tar.bz2

Then configure and compile it:

cd OpenCV-2.3.1
mkdir build
cd build
cmake -G "Unix Makefiles" ..
sudo make install

You can use different options when executing cmake:

  • -D BUILD_EXAMPLES=ON -> Compile example programs.
  • -D BUILD_TESTS=OFF -> Don’t compile tests.
  • -D BUILD_NEW_PYTHON_SUPPORT=OFF -> Don’t compile new Python support.
  • -D WITH_CARBON=ON -> (mostly for Leopard and below) To use Carbon instead of Cocoa (since version r2909).
  • -D WITH_QUICKTIME=ON -> (mostly for Leopard and below) To use QuickTime for the I/O of Video instead of QTKit (since version r2924). If you use Snow Leopard and need Carbon and QuickTime, you must also specify -D CMAKE_OSX_ARCHITECTURES=i386, -D CMAKE_C_FLAGS=-m32 and -D CMAKE_CXX_FLAGS=-m32.

If you don’t have cmake installed download a “binary distribution” from For example

You can compile OpenCV for an specific architecture using CMAKE_OSX_ARCHITECTURES with those values:


For example:

cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 ..

To create a “universal build” use both i386 and ppc:

cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 ppc ..

If you want to compile for a 32 bit architecture is mandatory to add -m32 to C and CXX flags. If you don’t add it you could end up with this warning:

created and used with differing settings of '-m32'

To solve this use -m32 option in CMAKE_C_FLAGS and CMAKE_CXX_FLAGS:

cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 -D CMAKE_C_FLAGS=-m32 -D CMAKE_CXX_FLAGS=-m32 ..

You might also like

Install OpenCV 2.4.2 with ffmpeg support in Mac OS X 10.8
In order to install OpenCV 2.4.2 with ffmpeg support we have to first install lamemp3, faac, faad and...
Install OpenCV in Ubuntu 10.10
If you want to install OpenCV 2.1 you can just use apt-get to do the work: sudo apt-get install libcv-dev...
Install OpenCV 2.3.1a in Ubuntu 11.10
If you want to install OpenCV 2.1 you can just use apt-get to do the work: sudo apt-get install libcv-dev...
Install OpenCV 2.3.1 in Ubuntu 12.04
OpenCV 2.3.1 is now the last version in repositories so you just need to run: sudo apt-get install...
Leave a comment ?


  1. cmake -G “Unix Makefiles” -D CMAKE_OSX_ARCHITECTURES=i386 ..
    results an error :
    ” CMake Error at CMakeLists.txt:69 (message):
    CMake fails to deterimine the bitness of target platform.

    Please check your CMake and compiler installation. If you are crosscompiling then ensure that your CMake toolchain file correctly sets the compiler details. ”

    I’m using opencv-2.4.2
    Any idea ?!


Leave a Comment