How to use OpenCV in a C++ file on the Google Colab?

I can successfully use OpenCV on my laptop for reading/processing images in C++ using VisualStudio.
On the Google Colab however, I get into problem.
The OpenCV is pre-installed on Colab, so we should be able to use it simply, but I fail to do it!
Can anyone post me a simple imread/imshow in C++ on the Google Colab from scratch?
P.S.: I assume there is no need to install anything on Jupyter, since OpenCV 4.7.0 is already installed on the jupyter.

Here is a snapshot of my code which fails to run, because of this error: undefined reference to `cv::imread


#include "cuda_runtime.h"

#include "device_launch_parameters.h"

#include <stdio.h>

#include <stdlib.h>

#include <cstdlib>

#include <time.h>

#include <chrono>

#include "../include/opencv4/opencv2/opencv_modules.hpp"

#include "../include/opencv4/opencv2/opencv.hpp"

#include "../include/opencv4/opencv2/core/core.hpp"

#include "../include/opencv4/opencv2/highgui/highgui.hpp"

#include "../include/opencv4/opencv2/imgproc/imgproc.hpp"

#include "iostream"

using namespace cv;

using namespace std;

#ifdef _DEBUG

#pragma comment (lib, "opencv_world412d.lib")


#pragma comment (lib, "opencv_world412.lib")


#define CHANNELS 3

//#define run_serial 1//1=serial, 2=OpenCV, 3=GPU

//#define run_opencv 2//1=serial, 2=OpenCV, 3=GPU

#define run_gpu 3//1=serial, 2=OpenCV, 3=GPU

int main()


const char* img_color_name = "remastered-lena-512x512.tiff";

cv::Mat img;

img = cv::imread(img_color_name);

// wait for a key



just curious,how do you try to compile this on colab ?

(to my surprise, i found complete opencv headers in /usr/include/opencv4 , but no libs or so’s at all)

((you also wont be able to run your windows / desktop code ‘as-is’,
there is no gui , #pragma is win only, etc))

for python, sure (via pip , totally unrelated to c++ dev !)