简体   繁体   中英

error LNK2019: unresolved external symbol cvSmooth referenced in function “void __cdecl example2_4(struct _IplImage *)”

I hope that anyone familiar with openCV and image processing will help me soon.
I'm absolutely new to openCV and VC++ and this is the third time this week, I've encountered the error LNK2019.
I know that this error means that the .lib file containing the specified function has not been linked to the project and it's appropriate header file has not been included at top of the code.
But this time based on this web page I glean that cvSmooth is the function included in opencv_imgproc243d.lib so I have added this .lib as the Additional Dependencies and have written the line

#include "opencv2\imgproc\imgproc.hpp"  

at top of my code but the error

error LNK2019: unresolved external symbol cvSmooth referenced in function "void __cdecl example2_4(struct _IplImage *)"  

does not change and remains the same.
I've been really confused????
Any help would be appreciated and if it's needed, tell me to add the code as an edited section to my question,please.
Is it wrong and cvSmooth belongs to another .lib file?


Edited section of my question based on h3now's suggestion

My code is as follows:

#include "stdafx.h"  
#include "opencv\cv.h"  
#include "opencv\highgui.h"  
#include "opencv2\core\core.hpp"  
#include "opencv2\imgproc\imgproc.hpp"  

void example2_4( IplImage* image )  
{
   // Create some windows to show the input  
   // and output images in.  
   //  
   cvNamedWindow( "Example4-in",CV_WINDOW_AUTOSIZE );  
   cvNamedWindow( "Example4-out",CV_WINDOW_AUTOSIZE );  
   // Create a window to show our input image  
   //  
   cvShowImage( "Example4-in", image );  
   // Create an image to hold the smoothed output  
   //  
   IplImage* out = cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3);  
   // Do the smoothing  
   //  
   // Do the smoothing  
   //  
   cvSmooth( image, out, CV_GAUSSIAN, 3, 3 );  
   // Show the smoothed image in the output window  
   //  
   cvShowImage( "Example4-out", out );  
   // Be tidy  
   //  
   cvReleaseImage( &out );  
   // Wait for the user to hit a key, then clean up the windows  
   //
   cvWaitKey( 0 );
   cvDestroyWindow( "Example4-in" );  
   cvDestroyWindow( "Example4-out" );  
}  




int main(int argc,  char* argv[])  
{  
    IplImage* img = cvLoadImage(argv[1]);
    example2_4( img );
    cvReleaseImage( &img );  
    system("pause");  
    return 0;  
}  

For example when I right-click on the function cvCreateImage and and choose Go To Definition a file named core_c.h gets opened. So understand that this function's prototype is included in core_c.h.
So for this reason we understand that we should write #include "opencv2\\core\\core.hpp" or #include "opencv2\\core\\core_c.h" (I think using any of the two codes makes no difference) at the top of our code and link opency_core243d.lib to the project to use the function cvCreateImage
But when I right-click on cvSmooth and choose Go To Definition , nothing happens
Does the solution that @h3now suggested work for all of the functions?
Because when I also right-click on cvShowImage, nothing happens.

I was having the same error. I'm using opencv 2.2 instead of 2.4.3, nevertheless the solution should be equivalent.

A good way to discover wich file you need to include is (in visual studio) right-clicking the function name in the code and selecting "Go to Definition". By doing this I realized that I should include the imgproc_c.h header file, instead of the imgproc.hpp .

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