Clangd works by partially compiling your file and parsing the AST. For source files (.cpp, .c, etc.), it just compiles that file directly, which should be fine.

For header files, it can't compile them directly, so it seems the current approach is to pick a source file that should match your header file. The problem is that this is based on heuristics and frequently fails, finding nonsense files inside your dependencies or elsewhere (see this issue or this one).

If this is your issue, you can diagnose it by opening the "clangd" language server output on Visual Studio Code, and looking for a line like this:

ASTWorker building file e:\your\folder\forehead\include.h version 1 with command inferred from E:\somewhere\else\Include.cpp

This is very annoying and I don't think there's a clean way around it. Except maybe renaming your file and some matching .cpp file to something more distinctive, like forehead_include.h and having a relevant forehead.cpp next to it? Otherwise, a name like include.h may be paired with random files somewhere else.

I have also had some partial success trying to include with quotes and relative paths, like #include "../forehead/include.h"

Answer from Daniel on Stack Overflow
Top answer
1 of 3
16

Clangd works by partially compiling your file and parsing the AST. For source files (.cpp, .c, etc.), it just compiles that file directly, which should be fine.

For header files, it can't compile them directly, so it seems the current approach is to pick a source file that should match your header file. The problem is that this is based on heuristics and frequently fails, finding nonsense files inside your dependencies or elsewhere (see this issue or this one).

If this is your issue, you can diagnose it by opening the "clangd" language server output on Visual Studio Code, and looking for a line like this:

ASTWorker building file e:\your\folder\forehead\include.h version 1 with command inferred from E:\somewhere\else\Include.cpp

This is very annoying and I don't think there's a clean way around it. Except maybe renaming your file and some matching .cpp file to something more distinctive, like forehead_include.h and having a relevant forehead.cpp next to it? Otherwise, a name like include.h may be paired with random files somewhere else.

I have also had some partial success trying to include with quotes and relative paths, like #include "../forehead/include.h"

2 of 3
2

There is one more workaround. It is quite ugly, but it helps. One can add paths into the .clangd file, in the CompileFlags section, Add subsection (link to the documentation). For example:

CompileFlags:
  Add:
    ... # some already existed flags
    - -I<path_1>
    - -I<path_2>
    - -I<path_3>
    ... # and so on

These paths can be added manually, or with a script that extracts them from the compile_commands.json. Write with quotes "-I<path_with_space>" in case of a path with spaces.

The drawback of this approach is that clangd adds these flags for all clang++ calls. Therefore we won’t know some build configuration issues for some source files until we start the build. But hints in VS Code will work fine.

🌐
GitHub
github.com › clangd › clangd › issues › 2411
file not foundclang(pp_file_not_found) · Issue #2411 · clangd/clangd
June 4, 2025 - with clangd) with c/c++) clangd is unable to find LLVM headers despite i have installed them correctly. C/C++ from microsoft can fetch it so im using it in the meantime but i miss clangd :( Logs clangd.log System information Output of cl...
Author   clangd
Discussions

cmake - clang in neovim giving pp_file_not_found error for c++/pytorch basic example - Stack Overflow
I'm following this very basic c++/pytorch example: pytorch_installing And I can walk through this example with no errors. However, when creating the example-app.cpp file (or editing it at any point... More on stackoverflow.com
🌐 stackoverflow.com
System include extraction successful, yet still `clang(pp_file_not_found)`
The deferred compiler include paths look all over the place with forward and backward slashes, but do point to the correct locations and these indeed contain the headers that will later be reported as clang(pp_file_not_found). I'm also a bit puzzled by the -- right before the CU, is that intended ... More on github.com
🌐 github.com
3
April 15, 2022
SDL pp_file_not_found
I have a problem with SDL library the program is compile correctly but I have an error in vim, coc-clangd do not see the library: the error is pp_file_not_found ` vim version: NVIM v0.4.3 node vers... More on github.com
🌐 github.com
5
August 2, 2020
Some system include paths are missing, and result in a header not found error
Clangd worked well with this project but suddenly everything turned wrong. So I delve into this issue and found the root problem is an error when resolving a dependency's header. It hinted In included file: 'sanitizer/asan_interface.h' file not foundclang(pp_file_not_found). More on github.com
🌐 github.com
7
June 14, 2024
🌐
GitHub
github.com › clangd › vscode-clangd › issues › 425
'iostream' file not foundclang(pp_file_not_found) · Issue #425 · clangd/vscode-clangd
December 15, 2022 - After I upgrade my system (ubuntu 22.04), it seems clangd cannot find standard libraries like iostream · This will produce the compile_commands.json:
Author   clangd
🌐
GitHub
github.com › clangd › clangd › issues › 1111
System include extraction successful, yet still `clang(pp_file_not_found)` · Issue #1111 · clangd/clangd
April 15, 2022 - The deferred compiler include paths look all over the place with forward and backward slashes, but do point to the correct locations and these indeed contain the headers that will later be reported as clang(pp_file_not_found). I'm also a bit puzzled by the -- right before the CU, is that intended ...
Author   clangd
🌐
GitHub
github.com › clangd › coc-clangd › issues › 74
SDL pp_file_not_found · Issue #74 · clangd/coc-clangd
August 2, 2020 - I have a problem with SDL library the program is compile correctly but I have an error in vim, coc-clangd do not see the library: the error is pp_file_not_found ` vim version: NVIM v0.4.3 node vers...
Author   clangd
🌐
GitHub
github.com › clangd › vscode-clangd › issues › 639
Some system include paths are missing, and result in a header not found error · Issue #639 · clangd/vscode-clangd
June 14, 2024 - Clangd worked well with this project but suddenly everything turned wrong. So I delve into this issue and found the root problem is an error when resolving a dependency's header. It hinted In included file: 'sanitizer/asan_interface.h' file not foundclang(pp_file_not_found).
Author   clangd
🌐
STMicroelectronics Community
community.st.com › t5 › stm32cubeide-for-visual-studio › header-files-not-found-by-vsc › td-p › 840112
Header files not found by VSC - STMicroelectronics Community
November 22, 2025 - I have problem that most headers are not visible so a lot of dependent problems occured. All files are present - the same project compoiled in STM32CubeIDE works. There is note that "clang(pp_file_not_found)" Tried to add paths in CMakeLists.txt but no luck.
Find elsewhere
🌐
GitHub
github.com › clangd › coc-clangd › issues › 441
wrong root path: clang pp_file_not_found · Issue #441 · clangd/coc-clangd
April 23, 2022 - However, clangd use encoder, so common/*.h cannot be found, but encoder/*.h can be found. 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). Logs Please attach the clangd log from :CocCommand workspace.showOutput if you can. If possible, run with --log=verbose - note that the logs will include the contents of open files!
Author   clangd
🌐
Reddit
reddit.com › r/cpp_questions › issues with vscode clangd and tdm-gcc
r/cpp_questions on Reddit: Issues with vscode clangd and tdm-gcc
October 21, 2023 -

I downloaded the latest TDM-GCC from jmeubank.github.io/tdm-gcc with default setup. So the files are located in C:\TDM-GCC-64.

I am using the clangd extension from vscode and I am having trouble setting it up. Searching the net I found that I had to add --query-driver=C:\TDM-GCC-64\bin\* to the argument list in clangd.arguments as well as make a file in the project folder named .clangd and have the following in the file

CompileFlags:
    Compiler: C:\TDM-GCC-64\bin\g++.exe

Now I am getting an issue I have no idea how to find a fix on the net. My code is

#include <bits/stdc++.h>
int main() {
}

I am getting the following error

In included file: 'math.h' file not foundclang(pp_file_not_found)
cmath(45, 15): Error occurred here

The line in question is

#include_next <math.h>

I can comment this out and it just goes to the next error which is

In included file: 'stdlib.h' file not foundclang(pp_file_not_found)
std_abs.h(38, 15): Error occurred here

which is

#include_next <stdlib.h>

I tried searching for include_next issues with clangd but they are all unresolved. So idk how to fix this.

Any help would be appreciated :)

🌐
GitHub
github.com › clangd › vscode-clangd › issues › 745
pp_file_not_found with MSVC (needs VS Developer environment) · Issue #745 · clangd/vscode-clangd
December 5, 2024 - When building with cmake, Ninja, and MSVC (instead of Visual Studio generator), then clangd can't find the needed path. The cmake configuration works and builds. the compile_commands.json is created and works fine. But clangd does not (c...
Author   clangd
🌐
GitHub
github.com › clangd › vscode-clangd › issues › 553
Header File Inclusion Error in C++ files with `vscode-clangd` extension · Issue #553 · clangd/vscode-clangd
November 21, 2023 - After installing this extension ... foundclang(pp_file_not_found). But it compiles without any problem. After googling i found lots of people also facing the same problem. But none of those mentioned soutions worked for me except one from this post stackoverflow.com, Where installing libstdc++-12-dev solved the missing header problem in C++ files: ... Is it possible to fix this without installing libstdc++-12-dev, So when a user install clangd extension ...
Author   clangd
🌐
Reddit
reddit.com › r/helixeditor › pp_file_not_found in cpp
r/HelixEditor on Reddit: pp_file_not_found in cpp
April 8, 2023 -

I am writing a code about openMP in c++ and when i type

#include <omp.h> i get the omp.h file not found error but when i compile it everying work without problems why this happen? and how can i solve It !

🌐
GitHub
github.com › clangd › clangd › issues › 2217
wrong pp_file_not_found · Issue #2217 · clangd/clangd
November 15, 2024 - Problem: When I attempted to use Clangd within VSCode to aid in writing kernel modules, I encountered unexpected 'file not found' errors. Please refer to the following image for the specific code and error messages: The image above illustrates the code I use to include the necessary header files.
Author   clangd
🌐
GitHub
github.com › clangd › clangd › issues › 2465
pp_file_not_found | cmake + compile_commands.json + clangd sometimes bugs when finding STATIC library linked to an INTERFACE library · Issue #2465 · clangd/clangd
August 17, 2025 - The issue arises on any file using the glad and the glm headers. clangd simply doesn't recognize these headers and errors pp_file_not_found, even though they build and compile fine.
Author   clangd
🌐
GitHub
github.com › clangd › vscode-clangd › issues › 503
wrong pp_file_not_found · Issue #503 · clangd/vscode-clangd
July 11, 2023 - clangd hint me In included file: 'Eigen/Core' file not foundclang(pp_file_not_found) but my compile_commands.json clear include the eigen package ·
Author   clangd
🌐
GitHub
github.com › clangd › clangd › issues › 224
clangd did not choose the correct mode for header file. · Issue #224 · clangd/clangd
December 10, 2019 - F:. compile_flags.txt foo.cpp foo.h compile_flags.txt -Wall foo.cpp #include "foo.h" foo.h #include // 'iostream' file not foundclang(pp_file_not_found) clangd did not choose the correct mode for the header file. I think clang...
Author   clangd
🌐
CERN
root-forum.cern.ch › t › vscode-intellisense-not-working-with-root › 42648
Vscode intellisense not working with root - ROOT - ROOT Forum
December 8, 2020 - ROOT Version: 6.18/04 installed with anaconda Platform: ubuntu 20.04lts Compiler: g++ vscode version: 1.51.1 The code is simple but somehow vscode does not know where to find “TH1F.h” even though I have told it where to find it. The error message is TH1F.h file not found clang(pp_file_not_...
🌐
Stack Exchange
vi.stackexchange.com › questions › 42139 › openmp-not-detected-by-clangd-despite-compile-commands-json
neovim - OpenMP not detected by clangd despite compile_commands.json - Vi and Vim Stack Exchange
May 9, 2023 - My program compiles fine, but within Vim (with CoC + clangd) I get the linting error: #include 'omp.h' file not found (clang pp_file_not_found) I use bear -- make as described in http...
🌐
Stack Overflow
stackoverflow.com › questions › 78661195 › iostream-file-not-found-clangpp-file-not-found-errror
c++ - 'iostream' file not found clang(pp_file_not_found) errror - Stack Overflow
Also you don't need c_cpp_properties.json at all, because that's for the Microsoft's C/C++ extension while you're using Clangd. Also the contents of that file are sus, because you're mixing two MinGW versions: the one from CB and TDM-GCC. ... You need to install Visual Studio(not visual studio code).It uses the path needed for the clangd binary that's needed for Zed C++ development