CVasquezG
CVasquezG

Reputation: 457

Is there a way to make sublime text or any other editor use gcc or g++ that is on the windows linux subsystem on windows 10?

Basically I want to find a way to use the gcc and g++ compilers that I have installed in the Linux Subsystem on my version of windows with any text editor.

I know on Linux you can build and run your C programs from sublime text. So has anyone found a way to interact with the WSL outside of bash?

Thanks and sorry for the confusing question.

Upvotes: 3

Views: 1781

Answers (3)

Vinggui
Vinggui

Reputation: 133

Complementing the answers here, you can use this mod of sublimeGDB that I made. It's working with sublime text 3 and GDB. some bugs, but works. You just need to clone it to the sublime plugging folder and remove the "_WSL". https://github.com/Vinggui/SublimeGDB_WSL

Upvotes: 1

Qrchack
Qrchack

Reputation: 947

This would be the answer, however you need to be running at least build #14951 of Windows 10, which is available only through Insider beta program. The reason is bash on windows by default has only stdio implemented - no pipes support (as in: will return error 0x80070057 if you try to use it in Sublime Text). As said, support has already been added, but since WSL is very much a beta thing, you need to be running latest Windows 10 builds. As a bonus, if you update, you'll have Ubuntu 16.04 support instead of 14.04

Sources:

Upvotes: 1

idleberg
idleberg

Reputation: 12882

You can pass any command to bash.exe using the -c switch, e.g. bash -c "ls" launches bash and lists the CWD. See the WSL Reference for details.

I'm not on Windows, but you could try and translate this to a build-system for Sublime Text. Create a new build system (Tools > Build System > New Build System…) and copy & paste the following:

{
  "selector" : "source.c",
  "cmd" : ["bash", "-c", "gcc \"$file_name\" -o \"${file_base_name}\""],
  "shell": true, /* or false? */
  "working_dir": "${project_path:${folder}}",
}

Please let us know if it works and I'll edit the example accordingly!

Update: Regarding error 0x80070057, you might have to disable legacy console in your Command Prompt properties (see the FAQ or this open issue for details!)

Upvotes: 2

Related Questions