我已经构建了 openCV 3.0.0 alpha 和 beta 版本。但是每次我运行我的项目时,我都会得到这个错误,只是因为“imread”功能:
error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class cv::String const &,int)" (?imread@cv@@YA?AVMat@1@ABVString@1@H@Z) referenced in function _main ...
这是我的代码:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <stdlib.h>
#include <stdio.h>
using namespace cv;
int main()
{
Mat a=Mat::zeros(10,10,0);
Mat b;
b=imread("Mu.jpg");
imshow("s",a);
waitKey(1000);
}
当我删除“imread”功能时,它工作正常。构建和运行没有错误并显示黑色小图像(来自“A”矩阵) 我从头开始重新构建解决方案和 OpenCV,但仍然出现此错误。
我正在使用 VS2012,我在项目的属性表中添加了包含和库路径。 有人可以帮忙吗?
最佳答案
imread
功能已移至 imgcodecs
库,所以你必须包含它:
对于MSVC用户:将“opencv_imgcodecs300d.lib”添加到“configuration properties->Linker->Input->Additional Dependencies”并包含“#include”
对于 Qt 用户:对于 Qt IDE 用户添加 -lopencv_imgcodecs300d
或 -lopencv_imgcodecs300
到您的 .pro 文件
和 #include <opencv2/imgcodecs/imgcodecs.hpp>
到你的主文件
注意: 应更改库名称中的数字 300 以匹配所用的 OpenCV 版本。
关于c++ - OPENCV 链接错误 - Win32 和 VS2012,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28624644/