解决unexpected end of file while looking for precompiled header directive

今天新建了一个工程打算把OpenCV的头文件和库文件放到工程文件夹中使用,以便今后拷贝只拷工程文件夹,不用安装OpenCV。

在 #include "stdafx.h" 里添加库函数

1 #pragma comment(lib,".//lib//cv.lib")
2 #pragma comment(lib,".//lib//cxcore.lib")
3 #pragma comment(lib,".//lib//highgui.lib")

图像处理类里添加头文件,头文件和库文件都是用相对路径

1 #include "./include/cv.h"
2 #include "./include/cxcore.h"
3 #include "./include/highgui.h"

编译的时候发现了一个错误:

fatal error C1010: unexpected end of file while looking for precompiled header directive

google别人的解决方法:

1、右键点工程名,选设置,然后选c/c++属性页,再选catagory选单中选 precompiled header ,将选项置成no use 或者autometic。

2、如果使用的是Win32工程,可能就是错误文件没有包含:#include "stdafx.h",添加该包含即可。

我使用方法2解决,类源文件需包含 #include "stdafx.h",而类的头文件不用包含。具体见stdafx.h、stdafx.cpp的作用

posted @ 2010-11-26 21:43  寒山月  阅读(17945)  评论(0)    收藏  举报