Here is the tutorial I followed:http://thebitbangtheory.wordpress.com/2011/10/23/how-to-install-opencv-2-3-1-in-ubuntu-11-10-oneiric-ocelot-with-python-support/
I think the problem is ffmpeg, the version I used is 0.8.10, and I installed it in /usr and enabled share, but when I complied opencv,the output was full of
./../lib/libopencv_highgui.so.2.3.1: undefined reference to
av_codec_get_id' ../../lib/libopencv_highgui.so.2.3.1: undefined reference to
av_seek_frame'
../../lib/libopencv_highgui.so.2.3.1: undefined reference to `avpicture_get_size