Reputation: 253
I downloaded MinGW following the first link here https://isocpp.org/get-started and now I need to configure it in SubimeText 3. I know I should go to Tools > Build System > New Build System... But what should I specify there?
I use Win7x64. And MinGW is in C:\MinGW
Upvotes: 2
Views: 20004
Reputation: 102852
The complete reference for build systems is here. The first thing you need to do is make sure that the C:\MinGW\bin
directory is in your PATH
, then restart Sublime so the change gets picked up.
Once you've done that, create a new build system with the following contents:
{
"cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,
"variants":
[
{
"name": "Run",
"cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
"shell": true
}
]
}
and save it as Packages/User/C.sublime-build
where the Packages
folder is the one opened by selecting Preferences -> Browse Packages...
.
You can now choose this build system by selecting Tools -> Build System -> C
. Once you are ready to compile, save your source file, then hit CtrlB to build. To run the program, hit CtrlShiftB and a cmd
window will open up to run the resulting .exe
file, then stay open until you close it (so you can see any output produced by the program).
You can try to use the C++
build system that comes with Sublime, but some users have run into issues with it in the past, especially on Windows, so this custom one may suit your needs better.
Good luck!
Upvotes: 10