0

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.

reiend
  • 1
  • 2
  • I inspect the and explore the file where bits/c++config.h located but I it wasn't there, this causing the linter issue. but I don't get it when I tried to build it, it works just fine. – reiend Apr 03 '22 at 10:34
  • after further exploration I found out that removing the LLVM on the path removes the linting error but it also removes the linting part lsp clangd. right now I reinstalling the llvm using via https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.0 I remembered that when I installed llvm using choco install somewhere in the middle of the download, it stops on a certain percent. so I stop it and reinstall it using the same method but it said that It was already installed, That's what I think so I continue. this probably cause the issue, maybe some missing files or sort of. – reiend Apr 03 '22 at 12:03
  • Update: after reinstalling llvm, linters are working again and completion, but still gives me a linting error of standard library not being found. – reiend Apr 03 '22 at 12:07
  • running clang++ -v gives me: clang version 14.0.0 Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: C:\Program Files\LLVM\bin – reiend Apr 03 '22 at 14:06
  • I forgot to mention that I also added -DCMAKE_CXX_LINK_FLAGS=-I on cmake flag. clangd reads the compile_command.json generated by cmake and the iostream but it missing something, the, it is located on the other folder on the same directory where iostream is located named x86_64-w64-mingw32/bits , I tried to copy its contents and added it to the /bits folder but it gives me another error and so on. – reiend Apr 03 '22 at 15:25
  • this is what I use to generate the build type cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS=" -IC:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\include\c++\11.2.0" "C:\Devs\software\cpp" – reiend Apr 03 '22 at 15:30
  • forget to mention that I a use gcc --version g++.exe (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 11.2.0 and for llvim I use 14.0.0 – reiend Apr 04 '22 at 02:03

2 Answers2

0

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

reiend
  • 1
  • 2
-1

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

reiend
  • 1
  • 2
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 04 '22 at 03:21