不在“工程->设置->LINK”下链接lib库而直接在,程序中链接的方法是,将.h头文件和.lib库文件放在工程目录下,然后在源程序中#include头文件,在使用关键字#pragma编译库文件,如下程序所示:
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"highgui.lib")
#pragma comment(lib,"cxcore.lib")
int main()
{
IplImage* img=cvLoadImage("test1.bmp",1);
cvNamedWindow("test",-1);
cvShowImage("test",img);
cvWaitKey(0);
cvDestroyWindow("test");
cvReleaseImage(&img);
return 1;
}