Skip to content
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

How can I use Unix headers of WSL? #2290

Closed
DemoCrazer opened this issue Jul 19, 2018 · 3 comments
Closed

How can I use Unix headers of WSL? #2290

DemoCrazer opened this issue Jul 19, 2018 · 3 comments

Comments

@DemoCrazer
Copy link

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(<sys/socket.h>, <sys/types.h>, ...) 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.

@bobbrow
Copy link
Member

bobbrow commented Jul 19, 2018

Have you seen this documentation?

@sirbabyface
Copy link

sirbabyface commented Nov 6, 2018

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.

@bobbrow
Copy link
Member

bobbrow commented Nov 7, 2018

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants