tl;dr: You need to tell clangd
how your project is built and where to find (non-standard) libraries, source files and headers etc., by generating compile_commands.json
or similar.
When using language servers, clangd
in this case, it needs to be told how the project is built. This includes, but is not limited to, compiler flags, linked libraries (and versions), header files in non-default locations, compiler, compiler version etc. Language servers for newer languages often just work™, but being C, the level of magic is low and you're expected to provide this info/configuration.
A widely adopted and supported way is to generate a compile_commands.json
file. Tools such as CMake support generating this file automatically for you, but it can also be generated manually (although I'd advice against it since it doesn't scale very well).