Ask Your Question

Revision history [back]

I've never used Visual Studio Code but, for your bare g++ example, you need to provide some arguments to tell it where to find OpenCV.

OpenCV should provide a pkg-config definition to make this easy, so try using locate opencv.pc to locate it (/usr/local/lib/pkgconfig/opencv.pc for my manual build) and then incorporating it into your g++ command like this:

gcc main.cpp `pkg-config --cflags --libs /usr/local/lib/pkgconfig/opencv.pc`

If that works, then you have a similar problem in Visual Studio Code and need to translate the flags echoed by pkg-config --cflags into project settings.