在VS平台下的C++项目,添加opencv的头文件失败问题的解决方法
报错:错误 1 error C1083: 无法打开包括文件: “opencv2/core.hpp”: No such file or directory
出现这种报错大概有以下几种原因,大家可以逐一排查
概括起来有以下三个方向:
1.项目属性配置是否正确
2.系统的环境变量是否配置正确
3.头文件的路径修改
将#include “opencv2/imgproc.hpp”
改为将#include"opencv2/imgproc/imgproc.hpp"
1.项目属性配置是否正确
确认是否在新建工程下成功配置了opencv的正确版本
(1)项目、属性、VC++目录、包含目录:
(2)项目、属性、VC++目录、库目录:
**(3)项目、属性、链接器、输入、附加依赖项:**填写附加依赖库的名字.lib 空格或分号间隔多项
opencv_ml249d.lib
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
opencv_legacy249d.lib
opencv_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib
opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.lib
opencv_calib3d249.lib
opencv_contrib249.lib
opencv_core249.lib
opencv_features2d249.lib
opencv_flann249.lib
opencv_gpu249.lib
opencv_highgui249.lib
opencv_imgproc249.lib
opencv_legacy249.lib
opencv_ml249.lib
2.系统的环境变量是否配置正确
此电脑、系统属性、高级、环境变量、path
添加opencv对应版本的路径
3.头文件的路径修改
报错原因可能是路径出错
可以看到在我的opencv安装路径下,这个文件夹里没有直接的imgproc.hpp
将#include “opencv2/imgproc.hpp”
改为将#include"opencv2/imgproc/imgproc.hpp"
问题解决