I’m having trouble telling to clangd where to search for my includes, so I want to use the inc folder inside the root folder of my project, but I can’t manage clangd to resolve my include paths, so I tried:
- adding a
compile_flags.txt
containing, amongst other flags,-Iinc
- generating a
compile_commands.json
file from my makefile, I just started this project so I can show the full file:
[
{
"directory": ".",
"command": "clang++ -Wall -Werror -Wextra -pedantic -Iinc -MMD -std=c++20 -c src/utils/invoke-daemon.cxx -o build/utils/invoke-daemon.o",
"file": "build/utils/invoke-daemon.o"
},
{
"directory": ".",
"command": "clang++ -Wall -Werror -Wextra -pedantic -Iinc -MMD -std=c++20 -c src/main.cxx -o build/main.o",
"file": "build/main.o"
}
]
- using
.clangd
, but I saw that it is not a valid option since.clangd
doesn’t support relative paths in flags.
Even with this compile_commands.json
at the root of my project, when I try to include a file contained in my inc
folder.
I after saw that the root_directory was set to /home/$USER
, so I changed it to be the current working directory, but I still get the same problem, clangd seems to just ignore compile_flags.txt
and compile_commands.json
So the only way I found that works to get the right include paths is to use .clangd
and put absolute path in -I
flag, because everything else I tried doesn’t work. And I want to include my config in git, and not having to run a script each time to generate the .clangd
with the right absolute path.