clangd still cannot find header files after specifying the include options

See original GitHub issue

I am using Windows 11, and I have downloaded the gcc compiler from mingw-w64, which should include all the basic system headers, and I am using clangd for vscode. For some reason, clangd still has a hard time trying to find all the basic header files, even when I specify multiple -isystemC:\path\to\includes. For example, clangd still fails to find bits/c++config.h. I have made a .clangd file to specify the includes.

CompileFlags:
  Add: [
    -std=c++20,
    "-isystemC:\\Users\\me\\Documents\\x86_64-12.2.0-release-posix-seh-rt_v10-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include",
    "-isystemC:\\Users\\me\\Documents\\x86_64-12.2.0-release-posix-seh-rt_v10-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\c++",
    "-isystemC:\\Users\\me\\Documents\\x86_64-12.2.0-release-posix-seh-rt_v10-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\c++\\x86_64-w64-mingw32",
    "-isystemC:\\Users\\me\\Documents\\x86_64-12.2.0-release-posix-seh-rt_v10-rev0\\mingw64\\include",
    "-isystemC:\\Users\\me\\Documents\\x86_64-12.2.0-release-posix-seh-rt_v10-rev0\\mingw64\\x86_64-w64-mingw32\\include"
  ]

Am I missing something? Sorry if this is not the place to get help with clangd.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
HighCommander4commented, Oct 15, 2022

The logs are showing that:

  1. --query-driver is now working, based on the following:

I[13:10:41.424] System includes extractor: successfully executed C:\Users\myuser\Documents\x86_64-12.2.0-release-posix-seh-rt_v10-rev0\mingw64\bin\g++.exe

  1. There are no diagnostics issued when you open testlib.cpp.

There are diagnostics issued when you open <iostream>, the reason for that is:

I[13:10:41.362] Failed to find compilation database for c:\Users\myuser\Documents\x86_64-12.2.0-release-posix-seh-rt_v10-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\12.2.0\include\c++\iostream

this can be fixed using https://clangd.llvm.org/faq#how-do-i-fix-errors-i-get-when-opening-headers-outside-of-my-project-directory.

0reactions
HighCommander4commented, Oct 15, 2022

Once https://github.com/clangd/clangd/issues/1089 is fixed, it should be enough to add:

CompileFlags:
  Compiler: /path/to/g++

to the clangd config file (and --query-driver=/path/to/g++ to the clangd command line), and compile_commands.json will not be required.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clangd cannot find a header file · Issue #695 - GitHub
Since header files don't have their own entries in compile_commands.json , clangd has to choose one of the source files which do have...
Read more >
Clangd errors in header files - LLVM Discourse
Right now I'm trying to use this setup to work in suckless org projects like dwm which consist of large .c files, configuration...
Read more >
Why can't Clang find my header files while GCC can?
a ) that I need to link to my code. I have the library in some "lib" folder inside some "src" folder. I...
Read more >
The clangd extension can't find includes : r/vscode - Reddit
I 've recently installed the clangd extension and its create in every way except it reports that header files are missing.
Read more >
Modules — Clang 8 documentation - bcain-llvm
Compile-time scalability: Each time a header is included, the compiler ... use -fmodule-map-file= option to explicitly specify the module map files to load....
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