Compile OpenCV 2.4.1 on Mac Os X Lion

1 minute read

After looking an episode of TBBT concerning a OCR iPhone app, I was considering to develop a real one or at least a prototype. From my old memories, I thought directly to the OpenCV library and I was glad to see that an android port was in high development stage. By the way, before trying to work on an Android OCR app, I wanted to start softly with a basic program on my Mac. On the main website I saw the simple way to get it worked was using fink, macports or homebrew :( Those tools are very good but I wanted a fresh compilation. I simply download the last stable version which uses the CMake system to compile all the framework. Really simple, but I experienced some linking errors that are due to, I suppose, to the fact that I don't have ffmpeg installed on my system. It seemed to miss a MP3 lame library and a faac library. 
Fisrt start by downloading and compile the lame library (3.99.5 worked fine) from

tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
sudo make install

Same thing with the faac library (1.28 worked fine) at

tar xjvf faac-1.28.tar.bz2
cd faac-1.28
sudo make install

The error came from the highgui module. To fixed it, I edited the modules/highgui/CMakeLists.txt to link to the previous compiled library.  You can use this patch file (patch -p0 < opencv_lion.patch) or edit the modules/highgui/CMakeLists.txt to add those lines :

 list(APPEND HIGHGUI_LIBRARIES ${BZIP2_LIBRARIES} -lmp3lame  -lbz2 -lfaac)

Leave a Comment