How to link opencv with c++ manually?

by benny_schoen , in category: General Help , 2 months ago

How to link opencv with c++ manually?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer


by cecelia , 2 months ago


To link OpenCV with C++ manually, you need to follow these steps:

Step 1: Install OpenCV

  • Download and install OpenCV from the official website (
  • Make sure to remember the installation directory.

Step 2: Create a C++ source file

  • Create a new C++ source file (e.g., main.cpp) and write your code.

Step 3: Include OpenCV headers

  • Include the necessary OpenCV headers at the beginning of your source file. For example:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

Step 4: Specify OpenCV library path

  • Open your compiler settings and specify the path to the OpenCV library.
  • Add the path to the OpenCV lib directory as an additional library directory.

Step 5: Link OpenCV libraries

  • Link the necessary OpenCV libraries to your project during the linking phase.
  • Append the following libraries to the linker settings: opencv_core, opencv_highgui, and any other required libraries.

Step 6: Build and run

  • Build your C++ program to compile and link it with OpenCV.
  • Run your program and verify that it runs successfully.

Note: The exact steps may vary depending on your compiler and operating system.