Sublime Forum

Bash on Windows

#1

I just installed the new Windows 10 preview build with a usable bash command line. I installed g++ with the hope that I could use it with sublime text in windows. I updated and rebooted but I can’t seem to get the g++ to be recognized when I build with sublime. Is there anyone out there using this to experiment with the new windows build? If not can anyone tell me what I need to install to compile C++ in windows so I don’t have to use visual studio… I would rather use the Linux command line tools if possible but I realize the bash on windows is still a work in progress, and I am still learning my way around in windows through this command line.

Thanks,

Lee

2 Likes

#2

I haven’t tried the “bash on Windows” functionality being added to Win10, but in one of the blog articles that announced the technology, this was said:

Run Bash on Ubuntu on Windows by Mike Harsh:

note that Bash and Linux tools cannot interact with Windows applications and tools, and vice-versa. So you won’t be able to run Notepad from Bash, or run Ruby in Bash from PowerShell.

I don’t remember what the exact technical reasons for this were, so I’m not sure if there’s a workaround.

If you just want to be able to compile Windows programs with gcc instead of MSVC, you can install a MinGW toolchain or Cygwin.

Cygwin also provides many of the common Linux command line tools. If you don’t want to use Cygwin, there are also various packages of Linux/unix tools that have been built to run on Windows.

0 Likes

#3

Have you installed and run Sublime from the Bash itself? like this

0 Likes

#4

Afaik, you can use something like bash.exe -c g++ <args>, but you need to translate the Win32 path of your current file to POSIX, e.g. /mnt/c/Users/johndoe/Desktop/source.cpp. Unfortunately, there seems to be no path translation tool like cygpath for Cygwin or winepath for Wine.

0 Likes

#5

I’ve been trying to do something similar, but to trigger make commands on a remote host via ssh (ignoring other ssh options, I wanted to try bash+ssh).

I currently have this simply build system for my project:
{ "name": "Bash", "shell_cmd": "C:\\Windows\\System32\\bash.exe -c date", "working_dir": "" }

And it gives the following output:

Running that same command (or more complex ones) from python’s subprocess.call() or from a cmd.exe console works fine. I’m going to try putting this into a cmd or bat file next. (update: cmd script shows the same NUL output)

1 Like