c++ - OPENCV 链接错误 - Win32 和 VS2012

标签 c++ opencv visual-studio-2012

我已经构建了 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/

相关文章:

c++ - 如何使用时间复杂度优于 O(n^2) 的 STL vector 和 STL 算法进行左连接?

使用 == 运算符的 C++ 字符串比较

c# - Visual Studio 2012 MVC 构建错误 : The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity'

visual-studio - F# Visual Studio 环境支持

visual-studio-2012 - Visual Studio session 管理

c++ - 为什么 _splitpath_s() 使用自定义大小的字符串缓冲区来返回驱动器号?

c++ - 模板化函数时链接器错误未找到析构函数

c++ - 曲线/路径骨架二值图像处理

android - 需要 "How To"来为 Android 和 NDK 11 重建 OpenCV v2.4.12 和 v.3.1

python - 在 OpenCV python 中打开具有未知扩展名的文件(Mjpeg?)