why does lsp clangd linting throws an error "bits/c++config.h file not found?

1.3k Views Asked by At

lsp linting clangd throws a linting error when doing an include e.g #include <iostream> error bits/c++config.h file not found

I already installed mingw(via choco install) and added it to my path also tried added the includes
enter image description here

same with LLVM! enter image description here

but when I tried to build a hello world program using cmake it works as expected. enter image description here

I also copied the compile_command.json to my root generated by cmake enter image description here

I been spending 2 days to solve this, but still no luck

here's the linting problem. (lsp clangd windows) enter image description here

any help is greatly appreciated.

2

There are 2 best solutions below

0
On

the include errors occur because of wrong lsp clangd config

Finally. ah. sigh.. I fixed it. I'm doing things wrong from the start. there's no need to add flags to include everything e.g -I that has been missing. There's nothing wrong on the clangd itself. The problem lies on your lsp config.

I'm using windows,powershell, no wsl, nvim -> lunarvim and cmake the fix is simple you just need to add the compile command path on your --query-driver on your clang lsp config

after that everything should work nice and smooth

1
On

the include errors occur because of wrong lsp clangd config

here is my solution for solving the issue

here's the path that you should have into your --query-driver, remember it depends on your compile_command.json.

compile_command.json generated by cmake

Your --query-driver should be the same as your command path listed on your compile_command.json

lsp clangd config

after that errors about missing includes should gone by now

errors gone