There are red wavy lines in the header file in VsCode (or an error message: Unable to open XXX)

Take the error when running the file in the OpenCV library as an example:

Problem Description:

  1. There are red wavy lines below the header file
  2. Ctrl click, the corresponding header file cannot be opened
  3. Run error: Unable to open source file XXX

In fact, the above three are all the same problem, which means that C++ cannot find the corresponding header file.

Solution: Add the c_cpp_properties.json file and add the corresponding header file path

Reference: Solving the problem that opencv cannot find the header file in vs code_jjuezzzzz_Jzzzzzzzzzz's blog-CSDN blog

  1. In vs code, ctrl+shift+p, select C/C++: Edit Configuration (UI),

At this time, a c_cpp_properties.json file will be automatically generated.

  1. Add the path to the corresponding header file after "includePath" in c_cpp_properties.json.

Still taking OpenCV as an example, add the following three lines, and the corresponding red wavy lines will disappear immediately (note the commas)

"D:/OpenCV/opencv/build/include",
"D:/OpenCV/opencv/build/include/opencv",
"D:/OpenCV/opencv/build/include/opencv2"

problem solved.

Guess you like

Origin blog.csdn.net/qq_45461410/article/details/132122136