简体   繁体   中英

OPENCV linking Error - Win32 & VS2012

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.

This unresolved external symbol linker errors basically arrives when the compiler is not able to get the definition of that function which is declared.

So make sure you have defined imread("Mu.jpg"){} somewhere in your code and then try compiling the same.

Check whether you have linked the libraries properly and also link may be useful if you are using opencv2.2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM