Failed to load image

Hi, I tried to run the following code in Visual Studio 2010 C++ but then it give an error: fatal error LNK1120: 6 unresolved externals

May I know what happen actually? TQ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>
using namespace std;
int main(int argc, char* argv[])
{
printf("Hello world\n");
IplImage *img = cvLoadImage("C:/Users/128A5S5/Desktop/21.jpg");
// Create a window
cvNamedWindow( "result",
CV_WINDOW_AUTOSIZE // allow window to resize to fit image true size
);
cvShowImage( "result", img ); // Show image in window already created
// Wait for a keystroke. If a positive argument is given, it will wait for
// that number of milliseconds and then continue. If 0 is given, the
// program will wait indefinitely for a keypress.
cvWaitKey(0);
// Clean up (not really necessary, but good programming practice)
cvReleaseImage( &img );
cvDestroyWindow("result");
system("PAUSE");
return EXIT_SUCCESS;
}
I haven't done any programming in Visual C++, but at first look at the error message, I would hazard a guess that it has little to do with your code, more to do with where certain files are that Visual Studio relies on. This is reinforced by the fact the error appears to be a link error (LNK...), which are in my experience due to not putting a file in the right place.

I would attempt to use a .BMP instead of a .JPG, as most windows programs seem to only accept bitmaps. You can use an online converter to do that.

Sorry i'm not much help, but maybe this'll get someone else to have a look at it with some knowledge of Visual C++.

Thanks,
hnefatl
Topic archived. No new replies allowed.