OPENCV链接错误-Win32& VS2012 [英] OPENCV linking Error - Win32 & VS2012

查看:78
本文介绍了OPENCV链接错误-Win32& VS2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我同时建立了alpha和amp;的openCV 3.0.0.测试版.但是每次我运行我的项目时,我只会针对"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,并且添加了include&项目属性表中的lib路径. 有人可以帮忙吗?

解决方案

imread函数已移至imgcodecs库,因此您必须包括它:

对于MSVC用户: :将"opencv_imgcodecs300d.lib"添加到配置属性->链接器->输入->附加依赖项"中,并包含"#include"

对于Qt用户: 对于Qt IDE用户,将-lopencv_imgcodecs300d-lopencv_imgcodecs300添加到您的.pro文件中 并#include <opencv2/imgcodecs/imgcodecs.hpp>到您的主文件

注释: 应该更改库名称中的数字300以匹配所使用的OpenCV 版本.

i have build openCV 3.0.0 both alpha & beta versions. but everytime i run my project i get this Error only for "imread" function:

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    ...

Here's my code:

#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);

}

when i remove the "imread" function it works fine. builds and runs with no errors and displays the little black image (from "A" Matrix) I have Re-Build the solutions & OpenCV from scratch and still getting this error.

I'm working with VS2012 and i have added the include & lib paths in a property sheet for the project. Can anyone help with this?

解决方案

imread function has been moved to imgcodecs library so you have to include it :

For MSVC users : add "opencv_imgcodecs300d.lib" to "configuration properties-> Linker->Input->Aditional Dependencies" and include "#include "

For Qt users : For Qt IDE users add -lopencv_imgcodecs300d or -lopencv_imgcodecs300 to your .pro file and #include <opencv2/imgcodecs/imgcodecs.hpp> to your main file

note: the number 300 in the lib name should be changed to match OpenCV version used.

这篇关于OPENCV链接错误-Win32&amp; VS2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆