Skip to content

programming

Why doesn't clangd LSP find my compiler's system headers?

When using clangd as LSP for C/C++ projects, e.g. in nvim, it enables all the nice convenience features we're used to from heavyweight IDEs like VS Code, Eclipse etc. Jump to definition, jump to references, autocompletion etc.

But sometimes, when using more complex compiler setups like multiple different compilers installed in parallel, cross compilation etc., it can suddenly fail to find standard includes like <fstream>, <string> (aka system headers), making it completely useless. What's happening there?