Sublime is a powerful cross-platform code editor, small and rich practical features are not comparable to Visual Studio, but the compilation run is a soft rib, this article through the sublime configuration g++ compiler implementation of the compiler function. A total of four steps are in practice:
- Download install sublime Text2 for Windows
- Download installation MinGW and system variable settings
- Sublime Building System Settings
- Compiling tests
One, download installs sublime Text2 for Windows: http://www.sublimetext.com/ Second, download the installation MinGW and system variable settings 2.1 Installing MinGWThis article uses the C + + compiler as gcc/g++, so you need to download the installation MinGW (: http://sourceforge.net/projects/mingw/)Software Installation Interface:
When the installation is complete, the user is asked to select the package to downloadSelect the package you want to download:
, after selecting MinGW Compiler Suite, add the GNU C + + Compiler related items. 2.2 Setting environment variablesRight-click My Computer, click Properties, Advanced-environment variables.
- In the environment variable path add the actual installation location of the system MinGW, such as: D:\Program Files\mingw or C:\MinGW\bin as demonstrated in this article. Add C:\MinGW\bin to Path (depending on your MinGW selection). If there are other variables in path, remember to add an English half-width semicolon. In general, the variables in PATH are very much, used between different variables;
- Create a new Library_path variable, if any, by adding C:\MinGW\lib to the value, which is the location of the standard library.
- Create a new C_includede_path variable with the value set to C:\MinGW\include.
- Check the variable settings: win+r input: cmd, enter on the command line: g++-V, with content input to prove that the environment variable is configured correctly. If ' g++ ' is not an internal or external command, it is not a program or batch file that can be run. Check the previous step configuration.
If the above screen shows that you have successfully installed, otherwise the environment variable setting problem. You need to modify the environment variables. Add the path to the MinGW before the environment variable that already exists. You need to restart your computer because Windows environment variables will not take effect immediately after they are modified. If you want to save trouble, do not want to restart the computer, you can directly enter the set path in the cmd C: \ \ Such environment variables will be forced to refresh. third, Sublime Building System settingsunder Windows, to compile, run C + + code in Sublime Text 2, you need to modify or create a new C + + compilation configuration. the specific is:Sublime Text 2 Tools, build system, NEW build system
enter the following and save the file as C++bulider.sublime-bulid.
{ "cmd": ["g++", "${file}", "-O", "${file_path}/${file_base_name}"], "File_regex": "^ (.. [^:]*]:([0-9]+):? ([0-9]+)?:? (. *) $ ", " Working_dir ":" ${file_path} ", " selector ":" Source.c, source.c++ ", " encoding ":" cp936 ", " Shell ": True, " variants ": [ { " name ":" Run ", //" cmd ": [" cmd ","/U ","/C "," g++ ${file}-o ${file_ Base_name} && ${file_base_name} "] " cmd ": [" Start "," ${file_path}/${file_base_name}.exe "] } ]}
Iv. Compiling tests after the above steps have been built to build up the C + + compiler environment, it is possible to compile and run C + + code in sublime Text 2. :
ctrl+b: Generatingctrl+shift+b: Run The resulting executable file is in the same directory as CPP:
Reprint http://blog.sina.com.cn/s/blog_6e7384df0101qzya.html
Sublime Text2/C + + compilation environment settings