Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'iostream' file not foundclang(pp_file_not_found) #425

Closed
HansLjy opened this issue Dec 15, 2022 · 5 comments
Closed

'iostream' file not foundclang(pp_file_not_found) #425

HansLjy opened this issue Dec 15, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@HansLjy
Copy link

HansLjy commented Dec 15, 2022

After I upgrade my system (ubuntu 22.04), it seems clangd cannot find standard libraries like iostream.

Minimum code:

#include <iostream>
int main() {
}

cmake file:

cmake_minimum_required(VERSION 3.22)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(Test)

add_executable(main main.cc)

commands:

mkdir build
cmake ..

This will produce the compile_commands.json:

[
{
  "directory": "/home/hansljy/tmp/test/build",
  "command": "/usr/bin/c++    -o CMakeFiles/main.dir/main.cc.o -c /home/hansljy/tmp/test/main.cc",
  "file": "/home/hansljy/tmp/test/main.cc"
}
]

The compilation is correct, but vscode complains with red wavelines and the message above

@HansLjy HansLjy added the bug Something isn't working label Dec 15, 2022
@HighCommander4
Copy link
Contributor

HighCommander4 commented Dec 15, 2022

Likely clangd/clangd#1394, please see workarounds in this comment.

@HansLjy
Copy link
Author

HansLjy commented Dec 20, 2022

Not working. I have gcc 11.3.0 installed on Ubuntu 22.04 so the first 2 options won't apply. This is my configuration (~/.config/clangd/config.yaml):

CompileFlags:
  Add: --include-dir=/usr/include/c++/11

After I setup the above config, vscode stops complaining my iostream but it is not responding to my ctrl + click on the header file and it did not know what std:: is, pretty annoying.

@HansLjy
Copy link
Author

HansLjy commented Dec 20, 2022

Plus, it has no problems finding the C standard libs, but it cannot identify C++ libs

@HansLjy
Copy link
Author

HansLjy commented Dec 20, 2022

Sorry, but the query driver way works. Thanks for the comment. But I was wondering how can I make this setting universal? I currently set the vscode config for clangd but I would like other code editor to be aware of the --query-driver option

@HighCommander4
Copy link
Contributor

Currently, --query-driver can only be set as a command-line argument to clangd, which are specified in your editor's configuration.

The reasons for this are security-related; there's some relevant discussion at clangd/clangd#539.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants