Recently I decided to update my OpenCV from 2.4 up to 3.2. I went through problems, and errors since am coding with C++ in Eclipse and using MinGW on Windows 10. After a little struggle, I finally got it running. Here is the step by step I used.

 

UPDATE: The latest version of OpenCV is now 3.3, to stay up-to-date please access the newer version of this article here. If for some reason you still want the 3.2 guide, ignore this note and continue.



 

Getting started

– You will need:

 

Configuring OpenCV

  • Add MinGW to System Path
    – Search for Environment variables;
    – Click on Path, and Edit;
    – Then, New, and add the address of your MinGW bin folder.

Adding environment variables

 

  • Extract OpenCV to a folder, rename it
    opencv_src
    – Inside it, create a folder named
    Mingw_build

 

Now, let’s compile OpenCV

  • Open CMake-gui;
  • set src folder as
    opencv_src
    and build folder as
    opencv_src/Mingw_build/

Setting build and source folder for OpenCV

 

  • Click on Configure, choosing
    Eclipse CDT4 - MinGW MakeFile
    in the next window, then next;
  • Wait for the entire configuration, then hit generate;
  • Now, open the CMD, and navigate to
    opencv_src/Mingw_build/
  • Inside
    opencv_src/Mingw_build
    type
    mingw32-make
    and hit enter;
    – This step probably will take a while, wait until it’s finished.
  • Install using
    mingw32-make install
  • Finally, add
    C:\opencv_src\Mingw_build\install\x86\mingw\bin
    to your system path.

 

Configuring Eclipse

  • Open it and create a C++ program using the following OpenCV  example:

 

  • Go to
    Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes
    and add the source OpenCV folder
    C:\opencv_src\Mingw_build\install\include

Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes

 

  • Go to
    Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries
    , and add this to the Libraries (-l), separately as shown in the image

 

Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries

 

  • You can  add additional libraries from lib folder if you need, just follow the presented format;
  • Add
    C:\opencv_src\Mingw_build\install\x86\mingw\lib
    to Library search path (-L);
  • Build the project. It will work flawlessly;
  • The code and configuration files can be found here.

 
 

 

 

Have fun with your projects! 
If this post helped you, please consider buying me a coffee 🙂