The solution is as follows:
First, add the path of the folder where your header file is located in "includepath":[]
of C_cpp_properties.json
.
Of course, this step is only to tell the vscode header file where it is for debugging, but it is not known when GCC compiles. We know that if you use G + + main.CPP - I library_path - O main
can be compiled successfully directly, so we just need to tell vscode to use our own defined commands
There are generally two methods. The first is to add “- I header_file_path” to the args key in tasks.json
, as follows:
"args": [
"-g",
"${workspaceFolder}\\src\\*.cpp",
"-o",
"${fileDirname}\\src\\${fileBasenameNoExtension}.exe",
"-I",
"header_file_path"
],
But it doesn’t seem to work well in some cases.
The second method is to directly set in setting.json
:
"code-runner.executorMap": {
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -I 'header_file_path' && $dir$fileNameWithoutExt",
}
Read More:
- [Solved] fatal error: bits/libc-header-start.h: No such file or directory
- [Solved] fatal error C1083: Could Not Open Unable to open include file:“stdint.h”: No such file or directory
- [Solved] MSYS2+ fatal error: zlib.h: There is no such file or directory
- [Solved] 1.fatal error: NvInfer.h: No such file or directory
- [Solved] fatal error C1083: Cannot open included files: “stdafx.h”: No such file or directory
- C++: fatal error: variant: No such file or directory
- fatal error: libusb.h: No such file or directory [How to Solve]
- [Solved] fatal error: Eigen/Geometry: No such file or directory
- [Solved] VScode Run C++ File Error: fatal error:opencv2\core.hpp:No such file or diretory
- Mac Vscode C++ Customize Header File Error: linker command failed
- [Solved] utils.c:33:18: fatal error: zlib.h: No such file or directory
- [Solved] src/delly.h:8:42: fatal error: boost/graph/adjacency_list.hpp: No such file or directory
- [Solved] ROS fatal error: alsa/asoundlib. h: There is no such directory or file
- [Solved] ERROR: Could not open requirements file: [Errno 2] No such file or directory : ‘requirments.txt‘
- SLAMBook2 in ch3 code run fatal error: Eigen/Core: No such file or directory
- error while loading shared libraries: lib*.so: cannot open shared object file: No such file or directory
- Centos pip install uwsgi error: “fatal error: Python.h: No such file or directory”
- [Solved] import mxnet Error: OSError: libcudart.so.8.0: cannot open shared object file: No such file or directory
- [Solved] import cv2 Error: ImportError: libGL.so.1: cannot open shared object file: No such file or directory
- [619]libgtk-3.so.0 or libXt.so.6: cannot open shared object file: No such file or directory