When you say the library cannot be found, do you mean:
- Error during cloud compile
- Error during local compile
- Intellisense has a red squiggle under the
#include
statement and indicates that the header file cannot be found.
If it’s the last one, I’ve seen this happen before, and I never found the root cause. However:
Try quitting and restarting VSCode. This probably won’t help, but it’s worth a try.
Make sure you have a .vscode directory in the top level of your project directory, and it contains settings.json. If you use Particle: Create New Project one is created, but if you created your project manually it will be missing, and the compiler settings may be wrong. There is also a launch.json that will affect the debugger.
If that doesn’t fix it, add the configurations
block below to settings.json. You may need to close and reopen the project to get it to update.
{
"extensions.ignoreRecommendations": true,
"C_Cpp.default.configurationProvider": "particle.particle-vscode-core",
"files.associations": {
"*.ino": "cpp"
},
"configurations": [
{
"name": "Libraries",
"includePath": [
"${workspaceFolder}/lib/**",
"${default}"
]
}
]
}
What this does is recursively add the directories in the lib directory to the include search path. The crazy thing is that you can then remove it, and it will still work. It seems to trigger something in VSCode that made the problem go away, at least for me.
The correct syntax for #include
is just the include file name, no path.