Take the error when running the file in the OpenCV library as an example:
Problem Description:
- There are red wavy lines below the header file
- Ctrl click, the corresponding header file cannot be opened
- 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
- 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.
- 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.