c++ - I get the Assertion failure "file_name != nullptr" but only in release mode
问题描述
When I try to run the code in debug mode everything works fine, but when I try to run it in release mode I get the error "file_name != nullptr"(the error comes from fopen). I know what the error means, but I don't know why I get the error and how to fix it
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
String imageName("C:/Users/x/Desktop/pic.png"); // by default
if (argc > 1)
{
imageName = argv[1];
}
Mat image;
image = imread(imageName, IMREAD_COLOR); // Read the file
if (image.empty()) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
Error Message:
>-----------Microsoft Visual C++ Runtime Library----------------
>
>
>Debug Assertion Assertion Faild!
>
>Programm: C:\Users\x\...\myProgramm.exe
>File: minkernel\crts\ucrt\src\appcrt\stdio\fopen.cpp
>
>Line: 30
>
>Expression: file_name != nullptr
解决方案
您必须确保在调试和发布模式下使用正确的依赖项(.lib 文件)。
推荐阅读
- php - 如何在 PHP 中存储 cookie 以唯一标识无需登录的用户投票
- python - 重写相同的代码得到不同的结果
- pandas - © 而不是 é 保存在 utf-8 文件中
- python - 在 Pandas Dataframe 中查找具有特定值的连续数据周期,并将它们分组为子数据帧
- c++ - 如何在 C++ 中将十六进制字符串转换为文本数据
- firebase - 是什么阻止了用户从 Firestore 中读取一百万次
- jmeter - 了解 JMeter 中的启动时间
- javascript - 如何从 WebView 中逃脱
- python - 在mysql数据库中插入“+”符号
- javascript - 生成数组Javascript的自定义对象