-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
WSL Include file not found in include path #710
Comments
I meet the same problem also.. VSCode Version: 1.12 |
I just had a similar issue trying to use VSCode with MinGW on Windows 10 (no Ubuntu on Windows in my case). And I have been able to solve it by adding the include paths to the "browse": {
"path": [
"/usr/include",
"/usr/local/include"
], It seems to be an inconsistency between the recommended property to edit ( |
@JirkaValtr Thanks for your solution. I am also using VSCode with MinGW on Windows 10. After I added the paths to the browse.path, I found that the C/C++ plugin complains that functions like 'fprintf'. 'fopen' are not defined although I did include <cstdio> or <stdio.h>(I tried both of them, they both don't work). Have you ever encountered the similar situations? Thanks. VSCode Version: 1.12.2 |
I tried to replicate your situation, but the following code ran fine for me, and the C/C++ plugin didn't complain about anything. #include <cstdio>
#include <cstdlib>
int main() {
FILE* fo = fopen("myfile.txt","w");
if (fo != NULL) fclose(fo);
} |
@zinechant What version of gcc and/or libc++ are you using? |
@JirkaValtr Thanks a lot for your reply. I have no clue why it doesn't work in my situation. |
@zinechant Probably there are more paths you need to add. If you open the #include files to see what squiggles they show, that might help diagnose the problem. I don't think we've tested on WSL yet, so there might be issues. |
Since you're on Windows, the IntelliSense mode defaults to Microsoft mode, not gcc/clang mode. We don't expose any controls to switch this right now, but you can see if replacing |
@bobbrow Thanks for your reply. It still not works. Will the control which can switch to gcc mode become a setting option in future release? |
Yes, it is on our backlog. |
That's great to hear...i am looking forward windows' version of visual code cpptools will support bash on ubuntu gcc mode |
@eesaber I had success with the following config:
An option to select clang/gcc mode on Windows is coming in the next update. I have tested it with MinGW on Windows and it works well for me. I will test it with WSL tomorrow. Watch the release notes for instructions. We'll add a FAQ for WSL with this config in it as well, since we're not going to auto-detect it for you right now. |
@bobbrow I success too. Thank you so much! |
I updated the config above after doing some testing with WSL. It now includes the new |
So...where is clang actually running here if I am using VSCode on windows10? Thanks |
@lurium Our clang-x64 mode doesn't run clang, it just makes our parser compatible with it. Is that what you're referring to? |
Yes, though I'm curious as to how you did this specifically. Is this behavior different if I run VSCode from linux? Thank you |
@lurium clang-x64 mode theoretically should behave the same on Windows and Linux, but parts of our code are compiled differently and use different library implementations on Windows/Linux, so there may be unintended differences (i.e. bugs on a particular platform, just like any other feature). |
For people like me who run across this topic from google, see: https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/Windows%20Subsystem%20for%20Linux.md |
This is one of the top links from google, and the link is out of date. 1) Ctrl+Shift+P then type
3) Ctrl+Shift+P then type Happy coding. |
@timothyr can you clarify why you think the WSL documentation is out of date? What you've posted looks like the "old" WSL config which is also in the documentation. |
@bobbrow I checked again and you're right, it's included. I missed it the first time because WSL has been out of beta for >9 months. Perhaps the labels should be switched. The current "Beta" instructions are working for the release, and the current "Release" instructions are deprecated. |
I use Ubuntu App for WSL with VSC, and I've followed cpptools WSL but still have the problem "Include Error".
|
@ab37695543xs I'm not able to repro the issue with my WSL setup and your c_cpp_properties.json settings. I'm not sure what the difference is...maybe your WSL version and/or the compiler/libs installed? I have clang-3.9 installed. If you install the insiders build (cpptools-win32.vsix at https://github.com/Microsoft/vscode-cpptools/releases/download/v0.16.0-insiders/ ) it will have more logging (the "sending compilation args" output) if you temporarily set the loggingLevel to the hidden value of "6", but the new compilerPath option doesn't work on Windows or WSL with that version (actually, WSL-basec compilerPath got post-poned till April, but Windows-based clang/gcc should work for March). |
@ab37695543xs, are you using a Windows Insiders build? We are tracking another WSL issue that looks similar to yours here: #1694 |
@bobbrow Yes, I'm using Windows Insider 17115, too |
Hello, I am a bash on Ubuntu on Windows user. And I've had some problems when I was programming in C++. When I put the headers (includes) then it appeared this: "include file not found in include path". How can I fix this? I try to add "/usr/include" into it as the figure shows.
in c_cpp_properties.json . But it does not works.
Thank you!
The text was updated successfully, but these errors were encountered: