SublimeText compiles the C development environment Settings

  • 2020-04-02 01:58:44
  • OfStack

The use of tools
Sublime does Text 2
MinGW

1. Configure environment variables

After downloading and installing Sublime Text 2 and MinGW, you need to add the Path of the Bin directory under the MinGW installation directory to the environment variable Path. As shown in figure:

< img SRC = "border = 0 / / files.jb51.net/file_images/article/201311/20131127165100.jpg? 20131027165628 ">

2. Call the C compiler through Sublime Text

Sublime Text has added configuration for the C/C++ compiler by default (compiled using g++ by default) by typing Ctrl+B. The compilation result will be input into the output field of ST, as shown in the figure:

< img border = 0 id = theimg onclick = window. The open this. (SRC) SRC = "/ / files.jb51.net/file_images/article/201311/20131127165144.jpg? 20131027165651 ">

3. Display the console output directly in Sublime Text 2

If you don't want to have to switch Windows and click on the exe generated by the compile every time you compile a file to see the results. Also in a simple configuration, directly display the console output results in ST, also do not need to switch the window, just need to call Ctrl+B after the compilation of Ctrl+Shift+B to run. Modify the Packages\C++\C++ under the Packages directory of Sublime Text to:


{
    "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",
    "variants":
    [
        {
            "name": "Run",
            "cmd": ["${file_path}\\${file_base_name}.exe"]
        }
    ]
}

 


Related articles: