I am following these instructions which belong to the openCV doc, but they are really outdated: iOS4 or iOS5 is mentioned, XCode 4.2 installed in /Developer, etc..
I
Instead of using terminal commands given in the opencv installation guide in official website, use the following commands. Worked for me.
cd OpenCV-2.3.1
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
sudo make install