at the moment I am using a windows machine and wanted to try out windows subsystem for linux(wsl) for c++ development. Visual studio code(vsc) provides a neat extension for working on the subsystem that works quite well. One thing I could not get to work yet is getting vsc to include header files that are located inside the subsystem.
I know that I can manually add new paths to include in ´c_cpp_properties.json´ but I do not know any of the paths to point from windows into the subsystems /usr/include(as an example). I found some resources (wsl include paths) but could not get it to work anyway. I also tried generating the paths myself as described in the gitlab issue but that did not help either.
Anyone got some experience setting up vsc with wsl for c++ projects who would be able to help me?
The question is missing some information, like what distro you're using and what setup steps you have followed. This means I will make some assumptions and repeat information you may already know.
Assumption: a Debian-based distro
sudo apt update && sudo apt upgrade -y && sudo apt install build-essential -y
You may also need to install git or cmake or whatever other tools are needed by your project.
Install the C/C++ extension into the remote. Install any other extensions that would be beneficial, like cmake if you're using cmake.
Settings that need to be changed (global)
"C_Cpp.default.compilerPath": "/absolute/path/to/your/compiler",
"files.eol": "\n",
"C_Cpp.default.cppStandard": "<SET>",
"C_Cpp.default.cStandard": "<SET>",
"C_Cpp.default.intelliSenseMode": "<SET>",
The last three need to be set according your company/project guidelines.
At this point, you should be able to write C++ code that uses the C++ Standard Library and have proper Intellisense working.
Your main question seems to be about adding project specific include paths. That is handled by the c_cpp_properties.json file. Your hard drives are located at /mnt
. Specify your paths. The better approach, though, is to simply use the VS Code variables. Something like ${workspaceFolder}/include
should be all you need.