Download extract MinGW to target directory, this installation of the decompression directory is C:\MinGW
Set environment variables. Right-click My Computer, Properties--advanced--environment variables.
Add C:\MinGW\bin in the System environment variable path (if there are other variables inside, remember to add the English semicolon;), click OK, OK, OK
Test that the MinGW is installed successfully. Win+r, run the cmd command line, execute g++-V in the cmd window, as shown below for success;
Click Preferences, then click Browse Package, new file C++.sublime-build file contents as follows:
{ "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"] } ]}
Write the test file Helloworld.cpp file contents as follows:
#include <iostream>using namespacestd;intMain () {intI;cout<<"input I:"<<endl;cin>>I;cout<<"i="<<i<<"HelloWorld"<<Endl;return 0;}
Press Ctrl+b to enter the value of the variable I, showing:
Congratulations, the configuration is successful!
Configuring compile and run C + + programs in Sublime Text 3