I am using VS Code remote via SSH to Raspberry Pi for my first C project. The code compiles without a problem, but the debugger can't find the header files. I have reviewed existing questions but the suggested solutions are not solving my problem.
If I place the header file in the root of my project, the file is found by the debugger.
Source, line 18:
#include "mfrc522.h"
The file is available in include
folder:
tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"--include-directory=${fileDirname}/**",
"--include-directory=${fileDirname}/include/**",
"--include-directory=${fileDirname}/src/*/*.c",
"--include-directory=${fileDirname}/*.c"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/include/**",
"${workspaceFolder}/**",
"${workspaceFolder}/src",
"${workspaceFolder}/src/*",
"${workspaceFolder}/src/*/*.c"
],
"browse": {
"path": [
"${workspaceFolder}/include/**",
"${workspaceFolder}/**",
"${workspaceFolder}/src",
"${workspaceFolder}/src/*",
"${workspaceFolder}/src/*/*.c"
]
},
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-arm64"
}
],
"version": 4
}
Resulting error:
main.c:18:10: fatal error: mfrc522.h: No such file or directory compilation terminated.
I had not seen this answer by bko earlier, which seems to have overcome the issue of including the header files.
What solved it for me was to just type folder path without /* or /** Then it prompted me if I want to enable Intellisense for this folder and I allowed it and it worked.