I wanted to use gcc
, g++
and make
from Sublime Text to be able to compile C and C++ code to Linux runnables on Windows. I couldn’t run bash.exe
from Sublime Text, as many other users on Stack Overflow.
Advertisement
Answer
You have to copy the
C:WindowsSystem32bash.exe
file to theC:WindowsSysWOW64
directory. Required because of the WoW64 file system redirection (Thanks Martin!)Then you have to create a new build system in the Sublime Text with the following code. (
Tools -> Build System -> New Build System...
){ "cmd" : ["bash", "-c", "gcc ${file_name} -o ${file_base_name} && ./${file_base_name}"], "shell": true, "working_dir": "${file_path}", }
This code will complile the .c code and than run it. The output will be shown in the Sublime’s Build Results panel.
When you want to use this Build System, select it in the
Tools -> Build System
list, then hitCtrl + B
.
You can customize the command I put there, the main thing is that you can run Linux commands using bash -c "CommandsYouWantToRun"