OpenCV read image error

I want to read my file with the example code posted on introduction website. But it seams has encoding error. How can I fix it?

My system is windows11 and opencv is 4.10. And I have tried 65001 UTF-8 encoding, it still has the problem.

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>



int main(int argc, char** argv)
{
	if (argc != 2)
	{
		std::cout << " Usage: " << argv[0] << " ImageToLoadAndDisplay\n";
		return -1;
	}

	cv::Mat image;
	image = cv::imread(argv[1], cv::IMREAD_COLOR); // Read the file

	if (image.empty()) // Check for invalid input
	{
		std::cout << "Could not open or find the image\n";
		return -1;
	}

	cv::namedWindow("Display window", cv::WINDOW_AUTOSIZE); // Create a window for display.
	cv::imshow("Display window", image); // Show our image inside it.

	cv::waitKey(0); // Wait for a keystroke in the window
	return 0;
}

please try to attach the resp. image, so we can take a look.

(it’s probably a misnamed .gif or such…)

also, opencv on windows has trouble with non-ascii file names.

But my file name is only ascii words(in the picture). It still has the problem.

ah right. then it’s a matter of linking the wrong libraries. that can cause corruption of string values.

Thank you very much. It seems the error that opencv_world4100d.lib causes. When I delete this line and switch to release. It works