c++clangatom-editorclangd

Clangd not finding standard headers


I am using Atom to write C++ code and have installed the llvm suite to use an Atom package which uses the clangd language server. It seems to be working, except that clangd doesn't seem to find the standard headers (e.g. iostream, algorithm). I installed llvm using the prebuilt Windows binaries. The error that shows up in the Atom Diagnostics pane is " 'algorithm' file not found".

Does anyone have any ideas what I can do to get clangd to find the standard headers?


Solution

  • I figured it out thanks to "How to use clang with mingw-w64 headers on windows".

    Using the llvm prebuilt binaries, clangd looks for MSVC libraries, which I did not have; I use the MinGW compilers.

    To have clangd look for the header files in the appropriate location, where the MinGW standard header files are located, I needed to include the compiler option:

    --target x86_64-pc-windows-gnu
    

    in the compiler_flags.txt or compile_commands.json file.