Skip to content

Commit 312a14a

Browse files
committed
Update docs for WSL config
1 parent d1d81de commit 312a14a

File tree

1 file changed

+68
-10
lines changed

1 file changed

+68
-10
lines changed

Documentation/LanguageServer/Windows Subsystem for Linux.md

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,61 @@
1-
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.
1+
# Windows Subsystem for Linux
2+
3+
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`.
4+
5+
Select "C/Cpp: Edit Configurations" from the command palette to create the **c_cpp_properties.json** file if you haven't already.
6+
7+
## Release
8+
9+
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.
10+
11+
```json
12+
{
13+
"name": "WSL",
14+
"intelliSenseMode": "clang-x64",
15+
"includePath": [
16+
"${workspaceRoot}",
17+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5",
18+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu/c++/5",
19+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5/backward",
20+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
21+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include",
22+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
23+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu",
24+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include"
25+
],
26+
"defines": [
27+
"__linux__",
28+
"__x86_64__"
29+
],
30+
"browse": {
31+
"path": [
32+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5",
33+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu/c++/5",
34+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
35+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include",
36+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
37+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu",
38+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/*"
39+
],
40+
"limitSymbolsToIncludedHeaders": true,
41+
"databaseFilename": ""
42+
}
43+
}
244

345
```
46+
47+
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.
48+
49+
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.
50+
51+
For C projects, simply remove the c++ lines:
52+
53+
```json
454
{
555
"name": "WSL",
656
"intelliSenseMode": "clang-x64",
757
"includePath": [
858
"${workspaceRoot}",
9-
"${localappdata}/lxss/rootfs/usr/include/c++/5",
10-
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
11-
"${localappdata}/lxss/rootfs/usr/include/c++/5/backward",
1259
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
1360
"${localappdata}/lxss/rootfs/usr/local/include",
1461
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
@@ -21,8 +68,6 @@ For developers using the Windows Subsystem for Linux, we recommend you start wit
2168
],
2269
"browse": {
2370
"path": [
24-
"${localappdata}/lxss/rootfs/usr/include/c++/5",
25-
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
2671
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
2772
"${localappdata}/lxss/rootfs/usr/local/include",
2873
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
@@ -33,19 +78,21 @@ For developers using the Windows Subsystem for Linux, we recommend you start wit
3378
"databaseFilename": ""
3479
}
3580
}
36-
3781
```
3882

39-
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.
83+
## Beta
4084

41-
For C projects, simply remove the c++ lines:
85+
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.
4286

43-
```
87+
```json
4488
{
4589
"name": "WSL",
4690
"intelliSenseMode": "clang-x64",
4791
"includePath": [
4892
"${workspaceRoot}",
93+
"${localappdata}/lxss/rootfs/usr/include/c++/5",
94+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
95+
"${localappdata}/lxss/rootfs/usr/include/c++/5/backward",
4996
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
5097
"${localappdata}/lxss/rootfs/usr/local/include",
5198
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
@@ -58,6 +105,8 @@ For C projects, simply remove the c++ lines:
58105
],
59106
"browse": {
60107
"path": [
108+
"${localappdata}/lxss/rootfs/usr/include/c++/5",
109+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
61110
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
62111
"${localappdata}/lxss/rootfs/usr/local/include",
63112
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
@@ -68,8 +117,17 @@ For C projects, simply remove the c++ lines:
68117
"databaseFilename": ""
69118
}
70119
}
120+
71121
```
72122

123+
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.
124+
125+
Note that `${localappdata}/lxss/rootfs/` is the path to the root of the filesystem for Bash on Ubuntu on Windows.
126+
127+
For C projects, simply remove the c++ lines as in the previous example.
128+
129+
---
130+
73131
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.
74132

75133
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/)!

0 commit comments

Comments
 (0)