visual studio/eclipse : error LNK2019: unresolved external symbol [...] referenced in function main

asked 2016-03-20 09:46:12 -0600

melidara gravatar image

updated 2016-03-20 10:41:55 -0600

I have a problem : error LNK2019: unresolved external symbol [...] referenced in function main

#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int main(int argc, char * const argv[])
{
    cvNamedWindow("P2", CV_WINDOW_AUTOSIZE); 
    //path to image ex : c:/Users/image.jpg
    CvCapture* capture = cvCreateFileCapture("path to image"); 
    IplImage* frame;

    while (1) { 
        frame = cvQueryFrame(capture);
        if (!frame) break; cvShowImage("P2", frame); char c = cvWaitKey(0); if (c == 27) break;
    } 
    cvReleaseCapture(&capture); cvDestroyWindow("P2"); 

    return 0;
}

image description

I start my project by following tutorial, the same configuration to use OpenCV with visual Studio and Eclipse but I have the same error.

edit retag flag offensive close merge delete

Comments

is that really the exact error message ?

berak gravatar imageberak ( 2016-03-20 10:33:18 -0600 )edit

you forgot to link opencv libs, which opencv version are you using ?

berak gravatar imageberak ( 2016-03-20 10:48:23 -0600 )edit

where did you find that code ? it's horribly outdated, and must not be used.

berak gravatar imageberak ( 2016-03-20 10:50:34 -0600 )edit

I use the last version of OpenCV on visual studio 2010. I have a problem with link opencv libs (example : I added opencv_ts300d.lib, error : LINK : fatal error LNK1104: cannot open file 'opencv_ts300d.lib') so I don't add link.

melidara gravatar imagemelidara ( 2016-03-20 11:39:17 -0600 )edit
  • i'm not sure, if there are prebuilt binaries at all for vs2010 nowadays.
  • please link against opencv_world300d.lib, and set the correct folder path in "Additional Library Dirs"
  • make sure, you use the correct confuguration (x64/x86) and the correct compiler version.
  • latest opencv version is 3.1.0, not 3.0.0
  • (you don't need the ts lib, it is only for unit tests)
berak gravatar imageberak ( 2016-03-20 11:56:25 -0600 )edit

The folder path : C:\opencv\build\include ? How do I know I use the correct confuguration (x64/x86) and the correct compiler version ?

melidara gravatar imagemelidara ( 2016-04-01 14:52:38 -0600 )edit