Last month I made a tutorial on how to build and install OpenCV 3.2 on Windows 10 using CMake and MinGW on Windows. Since then, I received some requests asking for a Linux equivalent one. So, here is the step-by-step.




Getting Started

  • Start running the well known apt-get update  and apt-get upgrade

 

Building and configuring Linux OpenCV

  • After that, install the required dependencies by using the following commands;

  • Download and extract the OpenCV source using the commands (you could change the version number to the one you want).

  •  Access the OpenCV folder and execute:

  • And then install with: sudo make install
  • Finish the installation creating the necessary link and cache to OpenCV library using:

  • Now reboot. OpenCV is ready to use.

 

Eclipse configuration

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

  •  If you want to make sure where the OpenCV is, enter
    pkg-config --cflags opencv
    in the terminal to see where it is installed;
  • Probably, it will be at
    /usr/local/include/opencv
  • Go to
    Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes
    and insert the OpenCV include path, as shown in the image.

 

Eclipse for Linux configuration steps 1

 

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

Eclipse for Linux configuration steps 2

  • Add the path to your libs  folder on Library search path (-L);
  • If you don’t know where it is, execute pkg-config --libs opencv
    • Probably, will be /usr/local/lib
  • Done! Build the project, and it’s finished.