Settings
We will suppose that the OpenCV library is installed in the C:\Program Files\OpenCV directory. Now, we have to configure DevCpp that he can take into account, all the includes files (.h), all the static libraries in OpenCV (.lib), and all the dynamic library (.dll) useful for the execution and not for the compilation. This configuration has been tested with the version 4.9.9.x of DevCPP. First of all, you have to indicate the header files you want to add. To do that, select Tools->Compiler Options.
. Then click on the plus sign to add a new compiler (in fact, only some different options) named here, OpenCV.
To finish, on the section Add the following ... write : -L"C:\Program Files\OpenCV\lib" -lcxcore -lcv -lcvaux -lhighgui -lml -lcvcam. Or the following for OpenCV 2.1 -L"C:\OpenCV2.1\lib" -lcxcore210 -lcv210 lcvaux210 -lhighgui210 -lml210
Include files configuration
Next, click on Directories and then on C Includes to add all the headers, located in some C:\Program Files\OpenCV subdirectories as shown in the picture. For OpenCV2.x, you will notice that there are changes in the overall directory structure and hence you won't find the folders shown in the image below. You only need to add C:\Program Files\OpenCV2.x\include\opencv in the include tab to get things to work. Of course, if you want to write C++ programs, do the same thing on the C++ Includes tab.
Static library files configuration
The following picture shows the static libraries paths to add.For OpenCV2.x there is no otherlibs\highgui folder and hence just adding C:\Program
FIles\OpenCV2.x\bin is sufficient.
Dynamic library files configuration
And to finish, add the bin directory where the dlls are:
Test
Let us choice a C program on the samples directory of OpenCV and try to execute it by typing F9. As you can see, all is OK.