Unable to compile CPP programs in Visual Studio Code using Jetson Nano

My basic code is:
#include <opencv2/opencv.hpp>


using namespace cv;

using namespace std;

int main(int argc, char** argv)


// Read the image file

Mat image = imread(“cv.jpg”);
// Rest of code…

The error I get is:
undefined reference to `cv::imread

And a few more like:
undefined reference to `cv::namedWindow

Just trying to do any C++ code with OpenCV and it fails.

This implies that the content providing namespace “cv::” was not configured to be found from your compile. I normally just work with Makefiles or command line, but your VS Code should have somewhere to configure where headers are for that namespace, and a linker search location to add anywhere the library content is. I couldn’t tell you where those files are, but I suspect if you check this thread out it will lead you to it:
(versions may differ since then)