这个是错的,原因在于#include "stdafx.h"不能放最后
#include "highgui.h"
#include "cv.h"
#include "stdafx.h"
int main(int argc, char* argv[])
{
IplImage* pImg;
return 0;
}
调换位置就可以了.
#include "stdafx.h"
#include "highgui.h"
#include "cv.h"
int main(int argc, char* argv[])
{
IplImage* pImg;
return 0;
}
原因是:
一般系统预编译的头文件包含在"stdafx.h" ,所谓头文件预编译,就是把一个工程中使用的一些标准头文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,不再编译这部分头文件,仅仅使用预编译的结果。这样可以加快编译速度,节省时间。
编译器通过一个头文件stdafx.h来使用预编译头文件。stdafx.h这个头文件名是可以在project的编译设置里指定的。编译器认为,所有在指令#include "stdafx.h"前的代码都是预编译的,它跳过#include "stdafx. h"指令,使用projectname.pch编译这条指令之后的所有代码。
因此,所有的CPP实现文件第一条语句都是:#include "stdafx.h"。