Vscode-cpptools: How can I use Unix headers of WSL?

Created on 19 Jul 2018  Â·  3Comments  Â·  Source: microsoft/vscode-cpptools

Describe the bug

  • OS and Version: Windows 10 Home 1803
  • VS Code Version: 1.25.1
  • C/C++ Extension Version: 0.17.6
  • A clear and concise description of what the bug is.
    I want to include some Unix headers(, , ...) to my C/C++ source file.
    Is it possible in VS Code? I'm using bash for integrated terminal but I couldn't figure out how to call Unix headers.
    For example, in CLion IDE, I can import Unix/Linux header files through SSH connection. I'm wondering can I do same thing in VS Code.
Language Service question

Most helpful comment

Have you seen this documentation?

All 3 comments

Have you seen this documentation?

What I did was adding to the c_cpp_properties.json file (inside .vscode folder) and add the include paths for the headers files of your WSL installation. In my case I add the following option:

"includePath": [ "C:\\Users\\<username>\\AppData\\Local\\Packages\\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\\LocalState\\rootfs\\usr\\include\\linux", "C:\\Users\\<usernname>\\AppData\\Local\\Packages\\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\\LocalState\\rootfs\\usr\\include" ],

The CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc might be different so you should check what contents do you have on your packages folder. It depends on the linux distro and version. I'm using Ubuntu version 16.

@sirbabyface, you should avoid putting the system include paths in the includePath setting. Use compilerPath instead and point it to /usr/bin/gcc so the extension can set the correct system include path and defines. (the extension will understand linux paths when you set the compilerPath in this way).

You can use wslconfig.exe to select which distro is the active one.

Was this page helpful?
0 / 5 - 0 ratings