0x01. Software Preparation:
Sublime Text 3
MinGW
0x02. Installation & configuration MinGW:
The path variable adds a C:\MinGW\bin
Note that this configuration requires a reboot to take effect, but there are ways to enforce it:
Verify that the variables are set successfully or not:
set path = C: / MinGW / bin;% PATH%;
Verify the success of variable setting:
mingw-get // If the MinGW interface appears, the setting is successful
Install g ++
mingw-get install gcc g ++
Verify the success of g ++ installation:
g ++ -v // Print out g ++ version information, indicating successful installation
0x03. Configure Sublime text 3
Open Tools-> Build System-> New Build System and type the following information:
{
"cmd": ["g ++", "$ {file}", "-o", "$ {file_path} / $ {file_base_name}"],
"file_regex": "^ (.. [^:] *): ([0-9] +):? ([0-9] +)?:? (. *) $",
"working_dir": "$ {file_path}",
"selector": "source.c, source.c ++",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/ c", "g ++", "$ {file}", "-o", "$ {file_path} / $ {file_base_name}", "&&", "cmd", "/ c", "$ {file_path} / $ {file_base_name}"]
},
{
"name": "RunInCommand",
"cmd": ["cmd", "/ c", "g ++", "$ {file}", "-o", "$ {file_path} / $ {file_base_name}", "&&", "start", "cmd", "/ c", "$ {file_path} / $ {file_base_name} & pause"]
}
]
}
After Ctrl + S, it will prompt to save, please make sure the format of the file name is "XXX.sublime-build"
XXX means random, I changed to "c ++. Sublime-build"
After this step is completed, select the solution you just saved in the Build System, that is, c ++
Then, in Preferences-> Key Bindings-User, you can fill in the following scheme:
{"keys": ["ctrl + alt + B"], "command": "build", "args": {"variant": "RunInCommand"}}
Here you can freely modify the running shortcut keys.
0x04. Use Note
C / C ++ source files must be run in a directory in English!
0x05.END
Use sublime text 3 to build a lightweight C / C ++ editor / compiler