VS2019:致命错误 C1083 无法打开头文件:'opencv.hpp' [英] VS2019:fatal error C1083 Cannot open header file: 'opencv.hpp'

查看:479
本文介绍了VS2019:致命错误 C1083 无法打开头文件:'opencv.hpp'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写代码的时候,也就是头文件opencv2/opencv.hpp"都没事,
VS2019确实可以看到",
换句话说,我可以使用opencv.hpp中的类,但只有在我编译项目时,才出现c1083

在添加DrawLine()函数之前,我编译了很多次,没有错误.然后我添加了函数DrawLine(..),发生了错误

这是全部源代码

a.h
a.cpp

//a.h#include使用命名空间 cv;类画布{垫 mat_canvas;无效初始化(){mat_canvas.create(1024,1024,CV_32FC3);}void DrawLine(float ax,float ay,float bx,float by);}

//a.cpp#include"a.h"void Canvas::DrawLine(float ax,float ay,float bx,float by){cv::line(this->mat_canvas,Point2f(ax,ax),Point2f(bx,by),Scalar(1,1,1));}

错误信息是:

fatal error C1083 无法打开头文件:'opencv.hpp':没有这样的文件或目录

我知道我可以创建一个新的解决方案并将我的旧解决方案移到它上面,但这需要时间,而且我实际上不知道这个问题是否会在我的新解决方案中再次发生

任何答案都会有帮助

解决方案

实际上大部分时间都存在缺少附加包含目录路径"或错误设置的可能性.

在 Visual Studio 中的位置:

在 Visual Studio 开发环境中设置这个编译器选项

  1. 打开项目的属性页"对话框.有关详细信息,请参阅设置Visual Studio 中的 C++ 编译器和构建属性.
  2. 选择配置属性 > C/C++ > 常规属性页.
  3. 修改附加包含目录属性.

视觉Studio 2019 C++项目配置

示例项目设置在以下链接中描述:示例设置

It is all fine when I was writing the code, that is, when I included the header file "opencv2/opencv.hpp",
and VS2019 can indeed "see" it,
in other words, I can use the class that is in the opencv.hpp, but only when I complied the project,c1083 occurred

before i added the function DrawLine(),i compiled for times,with no err.and then i added the function DrawLine(..),error occurred

this is the total source code

a.h
a.cpp

//a.h
#include<opencv2\opencv.hpp>

using namespace cv;

class Canvas{
    Mat mat_canvas;

    void Init(){
        mat_canvas.create(1024,1024,CV_32FC3);
    }

    void DrawLine(float ax,float ay,float bx,float by);
}

//a.cpp
#include"a.h"

void Canvas::DrawLine(float ax,float ay,float bx,float by){
    cv::line(this->mat_canvas,Point2f(ax,ax),Point2f(bx,by),Scalar(1,1,1));
}

error msg was:

fatal error C1083 Cannot open header file: 'opencv.hpp': no such file or dir

i know i can create a new solution and move my old solution to it,but it takes time,and i can't actually know whether this issue will happen again in my new solution

Any answer will be helpful

解决方案

Actually there are most of the time possibility of missing "Additional include directory path" or wrongly setup.

Where to find in Visual Studio:

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
  2. Select the Configuration Properties > C/C++ > General property page.
  3. Modify the Additional Include Directories property.

Visual Studio 2019 C++ Project configuration

Example project setup is described in below link: Example setup

这篇关于VS2019:致命错误 C1083 无法打开头文件:'opencv.hpp'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆