npchitman · 2022-04-19 12:24
[SOLVED] also discussed in [here](https://github.com/clangd/clangd/discussions/1113)
In my emacs, I use `lsp-emacs` + `clangd`, there are so many clangd error outputs but it can compile success, there's also happened in other projects. And when I use clion with clangd these errors are just gone and the syntax check outputs are the same as compiler compilation output.
These are my operations when I get starting with a project:
`cmake -B build -DCMAKE_EXPORT_COMPILE_COMMAND=YES -DCMAKE_BUILD_TYPE=Debug && ln -s build/compile_command.json .`.
Are there any operations and configurations I missed?
here's my [collected info](https://gist.github.com/K1ngst0m/ecc9d11860cc066e7d5b6a79d4dd4844) following the [troubleshooting guide](https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/)
fatnerdfromnextdoor · 2022-04-19 13:29
Same thing for me with VScode having much less errors(compiles fine).
I heard, that many language servers get overwhelmed with hacky,custom builds(which it is) so I stopped trying.
ram535 · 2022-04-19 16:33
The other day I was trying to configure lsp-mode, clangd and cmake.
And this worked for me. Run this commands in the root of the project.
- cmake -S . -B build
- cmake --build build
- cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON build
You do not need to symbolic link the `compile_caommand.json` file. `lsp-mode` will look for it in the `build/` directory by default.
Sometimes you have to restart `lsp-mode` with the command `lsp-workspace-restart`.
npchitman · 2022-04-19 16:46
Sometimes I need to generate build directory such as
build_platform/{debug,release}/xxx and that will cause `compile_command.json` not found without linking and I haven't understood how it works. Thanks for your tips.
But I tried your command and I thought that works the same as mine (same result with many errors in clangd which the compiler is working just fine).
amanol · 2022-04-19 16:57
Check the [clangd system headers](https://clangd.llvm.org/guides/system-headers) guide on how to handle some error cases. The guide is quite detailed on those cases.
This is the most common issue I used to have.
npchitman · 2022-04-20 01:34
ok, thanks for your help
KonpakuYoumu · 2022-04-20 08:07
`CMAKE_EXPORT_COMPILE_COMMANDS`.
The last `s` is missing in your command.
fatnerdfromnextdoor · 2022-05-09 20:27
This helped me: https://github.com/nickdiego/compiledb