Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Simple Opencv program with link error on

Hi everyone, I am a Opencv Newbie. I have downloaded and installed Opencv 2.4 according to the instruction, and after that I began writing my first Opencv program, which was basically a copy of the tutorial on the web.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std; 

int main( int argc, char** argv )
{ 
    if( argc != 2) 
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }

    Mat image;
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window
    return 0;
}

However, the program has several link errors although compiling seems fine. The link errors I have received are as follows:

Error   2   error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,int)" (?namedWindow@cv@@YAXABV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@H@Z) referenced in function _main    C:\Research\Projectivecorrection\Code\OpencvTest\OpencvTest\OpencvTest.obj
Error   1   error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@ABV_InputArray@1@@Z) referenced in function _main    C:\Research\Projectivecorrection\Code\OpencvTest\OpencvTest\OpencvTest.obj

Could anyone tell me what's wrong with my program? Thanks!

Simple Opencv program with link error on

Hi everyone, I am a Opencv Newbie. I have downloaded and installed Opencv 2.4 according to the instruction, and after that I began writing my first Opencv program, which was basically a copy of the tutorial on the web.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std; 

int main( int argc, char** argv )
{ 
    if( argc != 2) 
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }

    Mat image;
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window
    return 0;
}

However, the program has several link errors although compiling seems fine. The link errors I have received are as follows:

Error   2   error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,int)" (?namedWindow@cv@@YAXABV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@H@Z) referenced in function _main    C:\Research\Projectivecorrection\Code\OpencvTest\OpencvTest\OpencvTest.obj
C:\Research\OpencvTest\OpencvTest.obj
Error   1   error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@ABV_InputArray@1@@Z) referenced in function _main    C:\Research\Projectivecorrection\Code\OpencvTest\OpencvTest\OpencvTest.obj
C:\Research\OpencvTest\OpencvTest.obj

Could anyone tell me what's wrong with my program? Thanks!

Simple Opencv program with link error on

Hi everyone, I am a Opencv Newbie. I have downloaded and installed Opencv 2.4 according to the instruction, and after that I began writing my first Opencv program, which was basically a copy of the tutorial on the web.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std; 

int main( int argc, char** argv )
{ 
    if( argc != 2) 
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }

    Mat image;
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window
    return 0;
}

However, the program has several link errors although compiling seems fine. The link errors I have received are as follows:

Error   2   error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,int)" (?namedWindow@cv@@YAXABV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@H@Z) referenced in function _main    C:\Research\OpencvTest\OpencvTest.obj
Error   1   error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@ABV_InputArray@1@@Z) referenced in function _main    C:\Research\OpencvTest\OpencvTest.obj

Could anyone tell me what's wrong with my program? Thanks!

EDIT: A very tricky part of the problem is that if I use old-style Opencv function I will have no problem at all. The following codes can run very well:

int main( int argc, char** argv )
{
    char* filename = "C:\\Research\abc.pgm";  
     IplImage *img0;

    if( (img0 = cvLoadImage(filename,-1)) == 0 )
        return 0;

    cvNamedWindow( "image", 0 );
    cvShowImage( "image", img0 );
    cvWaitKey(0);  
    cvDestroyWindow("image");
    cvReleaseImage(&img0);



    return 0;
}