3

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?

RRostami
  • 33
  • 3
  • 1
    imread was moved from highgui to imgcodecs in 3.0, so , different header / lib – berak Feb 20 '15 at 10:21
  • Thank you very much!! it's fixed!!! it's wired thogh, because `imread` signature is also in highgui header, so only the lib file needed change, i guess it could be counted as bug... – RRostami Feb 20 '15 at 10:58
  • " because imread signature is also in highgui header" - i guess, that's more to faciliate the transition – berak Feb 20 '15 at 11:01

2 Answers2

3

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.

Chebhou
  • 148
  • 1
  • 16
Ahmed Yossef
  • 365
  • 3
  • 8
0

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.

Community
  • 1
  • 1
Shivaraj Bhat
  • 841
  • 2
  • 9
  • 20
  • [`imread()`](http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#imread) is *supposed* to be part of the opencv2 library, assuming it is being linked properly the error posted should't happen. It isn't something the user is supposed to have to *define*. – WhozCraig Feb 20 '15 at 08:45
  • How can i be sure that it's being linked properly? isn't "imshow" being linked and executed enough? – RRostami Feb 20 '15 at 09:07