-
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
Update WSL config docs #1176
Merged
Merged
Update WSL config docs #1176
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
178 changes: 117 additions & 61 deletions
178
Documentation/LanguageServer/Windows Subsystem for Linux.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,131 @@ | ||
For developers using the Windows Subsystem for Linux, we recommend you start with the following **c_cpp_properties.json** template. Select "C/Cpp: Edit Configurations" from the command palette to create this file if you haven't already. | ||
# Windows Subsystem for Linux | ||
|
||
``` | ||
{ | ||
"name": "WSL", | ||
"intelliSenseMode": "clang-x64", | ||
"includePath": [ | ||
"${workspaceRoot}", | ||
"${localappdata}/lxss/rootfs/usr/include/c++/5", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5", | ||
"${localappdata}/lxss/rootfs/usr/include/c++/5/backward", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/lxss/rootfs/usr/local/include", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/lxss/rootfs/usr/include" | ||
], | ||
"defines": [ | ||
"__linux__", | ||
"__x86_64__" | ||
], | ||
"browse": { | ||
"path": [ | ||
"${localappdata}/lxss/rootfs/usr/include/c++/5", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/lxss/rootfs/usr/local/include", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/lxss/rootfs/usr/include/*" | ||
], | ||
"limitSymbolsToIncludedHeaders": true, | ||
"databaseFilename": "" | ||
} | ||
} | ||
To use the Windows Subsystem for Linux with this extension you need to add a configuration to your **c_cpp_properties.json** file which adds the necessary header paths from within the WSL filesystem to the `includePath`. | ||
|
||
Select "C/Cpp: Edit Configurations" from the command palette to create the **c_cpp_properties.json** file if you haven't already. | ||
|
||
## Release | ||
|
||
For developers using Ubuntu with the current version of WSL released with the Fall Creators Update, you can add the following configuration template to your **c_cpp_properties.json** file. | ||
|
||
```json | ||
{ | ||
"name": "WSL", | ||
"intelliSenseMode": "clang-x64", | ||
"includePath": [ | ||
"${workspaceRoot}", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu/c++/5", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5/backward", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include" | ||
], | ||
"defines": [ | ||
"__linux__", | ||
"__x86_64__" | ||
], | ||
"browse": { | ||
"path": [ | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu/c++/5", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/*" | ||
], | ||
"limitSymbolsToIncludedHeaders": true, | ||
"databaseFilename": "" | ||
} | ||
} | ||
``` | ||
|
||
The `includePath` above includes the system header paths that gcc uses for C++ projects and matches the output of `gcc -v -E -x c++ - < /dev/null`. The intelliSenseMode should be set to **"clang-x64"** to get WSL projects to work properly with IntelliSense. | ||
|
||
Note that `${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/` is the path to the root of the Ubuntu filesystem. This will be different if you are using a different distro. | ||
|
||
For C projects, simply remove the c++ lines: | ||
|
||
```json | ||
{ | ||
"name": "WSL", | ||
"intelliSenseMode": "clang-x64", | ||
"includePath": [ | ||
"${workspaceRoot}", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include" | ||
], | ||
"defines": [ | ||
"__linux__", | ||
"__x86_64__" | ||
], | ||
"browse": { | ||
"path": [ | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/*" | ||
], | ||
"limitSymbolsToIncludedHeaders": true, | ||
"databaseFilename": "" | ||
} | ||
} | ||
``` | ||
{ | ||
"name": "WSL", | ||
"intelliSenseMode": "clang-x64", | ||
"includePath": [ | ||
"${workspaceRoot}", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/lxss/rootfs/usr/local/include", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/lxss/rootfs/usr/include" | ||
], | ||
"defines": [ | ||
"__linux__", | ||
"__x86_64__" | ||
], | ||
"browse": { | ||
"path": [ | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/lxss/rootfs/usr/local/include", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/lxss/rootfs/usr/include/*" | ||
], | ||
"limitSymbolsToIncludedHeaders": true, | ||
"databaseFilename": "" | ||
} | ||
} | ||
|
||
## Beta | ||
|
||
For developers using Bash on Ubuntu on Windows with the beta version of WSL from before the Fall Creators Update, you can add the following configuration template to your **c_cpp_properties.json** file. | ||
|
||
```json | ||
{ | ||
"name": "WSL (Beta)", | ||
"intelliSenseMode": "clang-x64", | ||
"includePath": [ | ||
"${workspaceRoot}", | ||
"${localappdata}/lxss/rootfs/usr/include/c++/5", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5", | ||
"${localappdata}/lxss/rootfs/usr/include/c++/5/backward", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/lxss/rootfs/usr/local/include", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/lxss/rootfs/usr/include" | ||
], | ||
"defines": [ | ||
"__linux__", | ||
"__x86_64__" | ||
], | ||
"browse": { | ||
"path": [ | ||
"${localappdata}/lxss/rootfs/usr/include/c++/5", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include", | ||
"${localappdata}/lxss/rootfs/usr/local/include", | ||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed", | ||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu", | ||
"${localappdata}/lxss/rootfs/usr/include/*" | ||
], | ||
"limitSymbolsToIncludedHeaders": true, | ||
"databaseFilename": "" | ||
} | ||
} | ||
``` | ||
|
||
The `includePath` above includes the system header paths that gcc uses for C++ projects and matches the output of `gcc -v -E -x c++ - < /dev/null`. The intelliSenseMode should be set to **"clang-x64"** to get WSL projects to work properly with IntelliSense. | ||
|
||
Note that `${localappdata}/lxss/rootfs/` is the path to the root of the filesystem for Bash on Ubuntu on Windows. | ||
|
||
For C projects, simply remove the c++ lines as in the previous example. | ||
|
||
--- | ||
|
||
With these configurations, you should be all set up to use the new IntelliSense engine for linting, memberlist autocomplete, and quick info (tooltips). Add `"C_Cpp.intelliSenseEngine": "Default"` to your **settings.json** file to try out the new IntelliSense engine. | ||
|
||
And remember to [heed the warnings of the Windows team about not creating or editing Linux files from a Windows app](https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/)! |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this works for Ubuntu, but what about OpenSUSE and SLES which are also available in the Windows Store? Should we provide configs for each of them?