Skip to content

Commit 6dfa9d6

Browse files
authored
Merge pull request #1176 from mezzode/wsl-config
Update WSL config docs
2 parents 53e8072 + aa4220c commit 6dfa9d6

File tree

1 file changed

+117
-61
lines changed

1 file changed

+117
-61
lines changed
Lines changed: 117 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,131 @@
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
22

3-
```
4-
{
5-
"name": "WSL",
6-
"intelliSenseMode": "clang-x64",
7-
"includePath": [
8-
"${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",
12-
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
13-
"${localappdata}/lxss/rootfs/usr/local/include",
14-
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
15-
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
16-
"${localappdata}/lxss/rootfs/usr/include"
17-
],
18-
"defines": [
19-
"__linux__",
20-
"__x86_64__"
21-
],
22-
"browse": {
23-
"path": [
24-
"${localappdata}/lxss/rootfs/usr/include/c++/5",
25-
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
26-
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
27-
"${localappdata}/lxss/rootfs/usr/local/include",
28-
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
29-
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
30-
"${localappdata}/lxss/rootfs/usr/include/*"
31-
],
32-
"limitSymbolsToIncludedHeaders": true,
33-
"databaseFilename": ""
34-
}
35-
}
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.
3610

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+
}
3744
```
3845

3946
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.
4047

48+
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.
49+
4150
For C projects, simply remove the c++ lines:
4251

52+
```json
53+
{
54+
"name": "WSL",
55+
"intelliSenseMode": "clang-x64",
56+
"includePath": [
57+
"${workspaceRoot}",
58+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
59+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include",
60+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
61+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu",
62+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include"
63+
],
64+
"defines": [
65+
"__linux__",
66+
"__x86_64__"
67+
],
68+
"browse": {
69+
"path": [
70+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
71+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include",
72+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
73+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu",
74+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/*"
75+
],
76+
"limitSymbolsToIncludedHeaders": true,
77+
"databaseFilename": ""
78+
}
79+
}
4380
```
44-
{
45-
"name": "WSL",
46-
"intelliSenseMode": "clang-x64",
47-
"includePath": [
48-
"${workspaceRoot}",
49-
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
50-
"${localappdata}/lxss/rootfs/usr/local/include",
51-
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
52-
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
53-
"${localappdata}/lxss/rootfs/usr/include"
54-
],
55-
"defines": [
56-
"__linux__",
57-
"__x86_64__"
58-
],
59-
"browse": {
60-
"path": [
61-
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
62-
"${localappdata}/lxss/rootfs/usr/local/include",
63-
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
64-
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
65-
"${localappdata}/lxss/rootfs/usr/include/*"
66-
],
67-
"limitSymbolsToIncludedHeaders": true,
68-
"databaseFilename": ""
69-
}
70-
}
81+
82+
## Beta
83+
84+
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.
85+
86+
```json
87+
{
88+
"name": "WSL (Beta)",
89+
"intelliSenseMode": "clang-x64",
90+
"includePath": [
91+
"${workspaceRoot}",
92+
"${localappdata}/lxss/rootfs/usr/include/c++/5",
93+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
94+
"${localappdata}/lxss/rootfs/usr/include/c++/5/backward",
95+
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
96+
"${localappdata}/lxss/rootfs/usr/local/include",
97+
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
98+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
99+
"${localappdata}/lxss/rootfs/usr/include"
100+
],
101+
"defines": [
102+
"__linux__",
103+
"__x86_64__"
104+
],
105+
"browse": {
106+
"path": [
107+
"${localappdata}/lxss/rootfs/usr/include/c++/5",
108+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
109+
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
110+
"${localappdata}/lxss/rootfs/usr/local/include",
111+
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
112+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
113+
"${localappdata}/lxss/rootfs/usr/include/*"
114+
],
115+
"limitSymbolsToIncludedHeaders": true,
116+
"databaseFilename": ""
117+
}
118+
}
71119
```
72120

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

75131
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)