Learning the Chinese version of opencv Chapter 2 example 2

Source: Internet
Author: User
It's a sin to play with image opencv! Books have already been purchased. Use them now. A problem occurs at the beginning. oh, mygod! Vs2008opencv2.3.1win7 program code: # includehighgui. hintmain (intargc, char * argv []) {IplImage * imgcvLoadImage(lena.jpg); cvNamedWindow (exa

It's a sin to play with image opencv! Books have already been purchased. Use them now. A problem occurred when I started using it. oh, my god! Vs2008opencv2.3.1win 7 program code: # include highgui. h int main (int argc, char * argv []) {IplImage * img = cvLoadImage(lena.jpg); cvNamedWindow (exa

It's a sin to play with image opencv! Books have already been purchased. Use them now. A problem occurred when I started using it. oh, my god!


Vs2008 + opencv2.3.1 + win 7


Program code:

# Include "highgui. h"


Int main (int argc, char * argv [])
{
IplImage * img = cvLoadImage ("lena.jpg ");
CvNamedWindow ("example1", CV_WINDOW_AUTOSIZE );
CvShowImage ("example1", img );
CvWaitKey (0 );
CvReleaseImage (& img );
CvDestroyWindow ("example1 ");
}


Generate a solution:

1> ------ all regenerate started: Project: learn_2-1, configuration: Debug Win32 ------
1> deleting the intermediate and output files for the project learn_2-1 (configure Debug | Win32)
1> compiling...
Learn_2-1.cpp
1> compiling resource list...
1> Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1> Copyright (C) Microsoft Corporation. All rights reserved.
1> link...
1> learn_2-1.obj: error LNK2019: external symbol that cannot be parsed _ cvDestroyWindow, which is referenced in function _ main
1> learn_2-1.obj: error LNK2019: an external symbol that cannot be parsed _ cvReleaseImage, which is referenced in function _ main
1> learn_2-1.obj: error LNK2019: the external symbol _ cvWaitKey that cannot be parsed, which is referenced in function _ main
1> learn_2-1.obj: error LNK2019: an external symbol that cannot be parsed _ cvShowImage, which is referenced in function _ main
1> learn_2-1.obj: error LNK2019: external symbol that cannot be parsed _ cvNamedWindow, which is referenced in function _ main
1> learn_2-1.obj: error LNK2019: an external symbol that cannot be parsed _ cvLoadImage, which is referenced in function _ main
1> d: \ Users \ legendary \ Documents \ Visual Studio 2008 \ Projects \ learn_2-1 \ Debug \ learn_2-1.exe: fatal error LNK1120: 6 External commands that cannot be parsed
1> the generated log is saved in file: // d: \ Users \ legendary \ Documents \ Visual Studio 2008 \ Projects \ learn_2-1 \ learn_2-1 \ Debug \ BuildLog.htm"
1> learn_2-1-7 errors, 0 warnings
============ All are regenerated: 0 are successfully generated, 1 is failed, and 0 are skipped ==========


Analysis:

A link error occurs, indicating that the static library is not found by the compiler.

Therefore, add Property -- linker -- input -- Additional dependency (debug:

Opencv_calib3d231d.lib
Opencv_contrib231d.lib
Opencv_core231d.lib
Opencv_features2d231d.lib
Opencv_flann231d.lib
Opencv_gpu231d.lib
Opencv_highgui231d.lib
Opencv_imgproc231d.lib
Opencv_legacy231d.lib
Opencv_ml231d.lib
Opencv_objdetect231d.lib
Opencv_ts231d.lib
Opencv_video231d.lib)

Note: 1. Do not add ";" at the end of the line. Otherwise, the following error may occur: 1> LINK: fatal error LNK1104: the file cannot be opened. Lib ";
2. if the downloaded OpenCV version is not 2.3.1, set "XXX231d. in lib "," 231 "is changed to the corresponding version number. For example, if OpenCV 2.4.0 is downloaded, it is changed to" XXX240d. lib ", otherwise the following error may occur: 1> LINK: fatal error LNK1104: Unable to open the file" XXX. lib ".

Property -- linker -- input -- add dependency (release:

Opencv_calib3d231.lib

Opencv_contrib231.lib

Opencv_core231.lib

Opencv_features2d231.lib

Opencv_flann231.lib

Opencv_gpu231.lib

Opencv_highgui231.lib

Opencv_imgproc231.lib

Opencv_legacy231.lib

Opencv_ml231.lib

Opencv_objdetect231.lib

Opencv_ts231.lib

Opencv_video231.lib)

At this point, the problem is solved!




Reference: http://www.opencv.org.cn/index.php/VC_2008_Express%E4%B8%8B%E5% AE %89%E8%A3%85OpenCV2.3.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.