question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

macOS C++ CMake project cannot find any C++ header file so clangd fails.

See original GitHub issue

Please describe the problem. For hints on what information is helpful, see: https://clangd.llvm.org/troubleshooting.html

If you can, provide a minimal chunk of code that shows the problem (either inline, or attach it if larger).

C++ file where #Include <memory> or really any standard C++ file is included. None of the includes will resolve.

Logs Please attach the clangd log from the “Output” window if you can. If possible, run with --log=verbose - note that the logs will include the contents of open files! clangd.log

System information Clangd version : 11.0.0 clangd extension version: 0.1.11 Operating system:macOS 10.15

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mrexodiacommented, Dec 17, 2021

I found add qurey driver help to make it work

  "clangd.arguments": [
+    "--query-driver=/usr/bin/clang++",
  ],

I think this should be the default setting on macos, it was a pain to find this.

0reactions
dmorncommented, Dec 6, 2022

Hey, if someone ends on this issue like me I found this snippet from the installation page very useful! It helps generating a compile_commands.json that clangd will use to find your project’s deps 😉

If your project builds with CMake, it can generate this file. You should enable it with:

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1
compile_commands.json will be written to your build directory. If your build directory is $SRC or $SRC/build, clangd will find it. Otherwise, symlink or copy it to $SRC, the root of your source tree.

ln -s ~/myproject-build/compile_commands.json ~/myproject/
  • tested on helix editor only but hey, this is the conversation I first got into
Read more comments on GitHub >

github_iconTop Results From Across the Web

clang-tidy can't locate stdlib headers - Stack Overflow
I add arg "--query-driver=/usr/bin/clang++" to clangd, and it works fine now, the headers can be found now. C++ headers should be in folder...
Read more >
Clangd does not recognize basic headers (cpp file) · Issue #556
coc-clangd doesn't recognize basic headers (I only use it for C++, don't know about C), such as string and iostream.
Read more >
Clang linking error MacOS Big Sur | Apple Developer Forums
Hi All, I am trying to build my helloworld.cpp, but I am having problem since I updated to Big Sur. Below a verbose...
Read more >
CMAKE_EXPORT_COMPILE_C...
When using a g++ compiler for build, the clang-tidy program does not find the c++ header.
Read more >
System headers - What is clangd?
You should first try executing the command from CDB to see if it can compile your file. If it can't, it means you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found