Undefined symbol: cv::imwrite when linking with Qt Creator

Hello,

I have tried that too. This is my current code:

#include <opencv2/opencv.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
using namespace cv;

int main()
{
    // Create a VideoCapture object to capture from the camera
    VideoCapture cap(0);

    // Check if the camera is opened successfully
    if (!cap.isOpened())
    {
        std::cout << "Error opening video capture" << std::endl;
        return -1;
    }

    // Set the desired frame width and height
    cap.set(cv::CAP_PROP_FRAME_WIDTH, 640);
    cap.set(cv::CAP_PROP_FRAME_HEIGHT, 480);

    // Capture a frame
    Mat frame;
    cap.read(frame);

    // Save the frame to disk
    std::string filename = "captured_image.jpg";
    cv::imwrite(filename, frame);

    // Release the VideoCapture object
    cap.release();

    return 0;
}

However, I get the same error:

ld: error: undefined symbol: cv::imwrite(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, cv::_InputArray const&, std::__ndk1::vector<int, std::__ndk1::allocator<int> > const&)
>>> referenced by main.cpp:29
>>>               CMakeFiles/androidnotifier.dir/main.cpp.o:(main)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/androidnotifier.dir/build.make:135: libandroidnotifier_arm64-v8a.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:225: CMakeFiles/androidnotifier.dir/all] Error 2
make: *** [Makefile:91: all] Error 2