The latest version of OpenCV 2.3.1 supports more and faster functions. Installation is straight forward:

Step 1. Get the latest version of OpenCV from the following link.

Step 2. Extract the source code in a working directory, <working_directory>.

Step 3. Goto the working directory, and compile the code.
cd <working_directory>/OpenCV-2.3.1
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
make
sudo make install
Step 4. Add the path to the dynamic libraries, and reload the libraries:
sudo gedit /etc/ld.so.conf.d/opencv.conf
==> Insert the following line: /usr/local/lib
sudo ldconfig
Step 5. Installation is completed. OpenCV can be tested, and examples can be compiled using:
cd <working_dir>/OpenCV-2.3.1/release/bin
==> As you can see, several functions_test are available
./opencv_test_core
 
cd <working_dir>/OpenCV-2.3.1/samples/c
sh build_all.sh
==> Example running delaunay.
./delaunay
Important Note. Since OpenCV version 2.2, the OpenCV libraries have been reorganized. See this link for more information. Therefore the Makefile is different compared to OpenCV versions prior to 2.2. The different functions are contained in smaller modules. Thus it can happen that a particular function cannot be found using the Makefile below. If this is the case, run the following command to find the library in which the function is contained, and add this library to your Makefile.
grep -r "command_name*" /usr/local

An example of a Makefile is given below.

objects = bvs.o functions.o
opencvOptions = -I"/usr/local/include/" -L"/usr/local/lib" -lopencv_core -lopencv_highgui
programName = bvs

$(programName): $(objects)
g++ -o $@ $(objects) $(opencvOptions)

%.o: %.cpp
g++ -c $< $(opencvOptions)

clean:
rm -f *.o $(programName)