How to check for openCV on Ubuntu 9.10

A proper answer to my own question !

pkg-config --modversion opencv


With OpenCV 2.4.x:

You can use "CV_VERSION" or "CV_MAJOR_VERSION", "CV_MINOR_VERSION", "CV_SUBMINOR_VERSION" from a C/C++ simple program.

Example of 'main.c':

#include <stdio.h>
#include <cv.h>

int main(void)
{
    printf("%s\r\n", CV_VERSION);
    printf("%u.%u.%u\r\n", CV_MAJOR_VERSION, CV_MINOR_VERSION, CV_SUBMINOR_VERSION);
}

Here is the compilation line:

g++ `pkg-config --cflags opencv` main.c `pkg-config --libs opencv` -o main