When upgrading from 11.10 to 12.04 and from Electric to Fuerte OpenCv are causing problems. You have to make sure you only have the correct version of OpenCV. Use Synaptic, apt, aptitude or something similar to check which packages are installed on you system. Once that is done do the following.
Make sure you have the file
/usr/lib/pkgconfig/opencv-2.3.1.pc
and that it looks like this
# Package Information for pkg-config prefix=/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir_old=${prefix}/include/opencv-2.3.1/opencv includedir_new=${prefix}/include/opencv2 includedir_ros=/opt/ros/fuerte/include Name: OpenCV Description: Open Source Computer Vision Library Version: 2.3.1 #Libs: -l${exec_prefix}/lib/libopencv_contrib.so.2.3.1 -l${exec_prefix}/lib/libopencv_legacy.so.2.3.1 -l${exec_prefix}/lib/libopencv_objdetect.so.2.3.1 -l${exec_prefix}/lib/libopencv_calib3d.so.2.3.1 -l${exec_prefix}/lib/libopencv_features2d.so.2.3.1 -l${exec_prefix}/lib/libopencv_video.so.2.3.1 -l${exec_prefix}/lib/libopencv_highgui.so.2.3.1 -l${exec_prefix}/lib/libopencv_ml.so.2.3.1 -l${exec_prefix}/lib/libopencv_imgproc.so.2.3.1 -l${exec_prefix}/lib/libopencv_flann.so.2.3.1 -l${exec_prefix}/lib/libopencv_core.so.2.3.1 Libs: -lopencv_contrib -lopencv_legacy -lopencv_objdetect -lopencv_calib3d \ -lopencv_features2d -lopencv_video -lopencv_highgui -lopencv_ml \ -lopencv_imgproc -lopencv_flann -lopencv_core Cflags: -I${includedir_old} -I${includedir_new} -I${includedir_ros}