clangd: Clangd does not recognize basic headers (cpp file)

coc-clangd doesn’t recognize basic headers (I only use it for C++, don’t know about C), such as string and iostream.

Capturar

System information Clangd version (from the log, or clangd --version): 10.0.0 Operating system: Windows 10

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (6 by maintainers)

Most upvoted comments

you just need to sudo apt-get install libstdc+±12-dev

you just need to sudo apt-get install libstdc+±12-dev

Anybody arriving here that uses Linux, try that suggestion before anything else. It quickly solved the issue to me.

Please provide clangd logs, preferably by passing -log=verbose to clangd. See http://clangd.llvm.org/troubleshooting.html#gathering-logs for details.

you just need to sudo apt-get install libstdc+±12-dev

Anybody arriving here that uses Linux, try that suggestion before anything else. It quickly solved the issue to me.

Same!

That is kind of counterintuitive. I’d expect no restriction when --query-driver=... is not provided.

It’s a security measure, intended to make the operation of checking out a potentially-untrusted repository and opening an editor that uses clangd to browse it, safer.

Without this in place, a malicious repository owner could include evil_script in their repository, along with a compile_commands.json which contains compiler commands with evil_script as the compiler, and clangd would run evil_script as part of its attempt to determine the compiler’s built-in include paths.

Sorry if docs weren’t clear, but you should grab the logs within your editor not by invoking clangd directly. That way we can see the interactions such as you opening files, clangd trying to find compile commands for those and such.