Home > Development Tools > sublime > body text

Detailed explanation of how sublime builds a C/C++ compilation environment

藏色散人
Release: 2021-02-19 17:55:16
forward
2835 people have browsed it

下面由sublime教程栏目给大家详解sublime搭建C/C++编译环境方法,希望对需要的朋友有所帮助!

Detailed explanation of how sublime builds a C/C++ compilation environment

sublime搭建C/C++编译环境(超完美的配置并配上内容详细讲解!!)

简述

有两台电脑,之前的电脑上就有之前好基友分享的cpp配置。
但是另外一台电脑上,一开始就没有配置这个。

然后,在网上搜,发现搜到的那些配置。抱歉,我的意思是,在坐的各位都是垃圾


我的C/C++的配置是这样的

  • 操作方式: 点击**工具,再选编译系统,再选新建编译系统**
  • 然后,把下面的代码,全部复制,并且,替换掉原来的那些地方。
  • 之后保存就好了。 比如说,我保存的文件名就是CPP.sublime-build

然后,我使用的时候,在选中了一个*.cpp文件,在键盘上输入**ctrl+b**(如果是第一次的话,会弹出下面的框,让你来选;否则就会需要输入ctrl+shift+b 这里关于输入法的必须选英文,否则会有表情包出来的。。)

Detailed explanation of how sublime builds a C/C++ compilation environment

  • 就可以看到前置的那些选项了。最后面会讲解下,这几个选项的含义:
{ 
    "cmd": ["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}", "&", "start", "cmd", "/c", "${file_path}\\\\${file_base_name} & echo. & pause"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}",
    "selector": "source.c, source.c++", "shell": true,
    "encoding":"cp936", 

    "variants":
    [
        {
            "name" : "Build Only",
            "cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}"]
        },
        {
            "name" : "Run Only",
            "cmd" : ["start", "cmd", "/c", "${file_path}\\\\${file_base_name} & echo. & pause"]
        },
        {
            "name" : "Pipe Build and Run",
            "cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}","&","${file_path}\\\\${file_base_name}", "<","${file_path}\\\\in",">","${file_path}\\\\out"]
        },
        {
            "name" : "Pipe Run Only",
            "cmd" : ["${file_base_name}", "<","in",">","out"]
        },
        {
            "name" : "Project Build & Run",
            "cmd" : ["g++", "${file_path}\\\\*.cpp", "-std=c++11", "-o", "${file_path}\\\\project", "&", "start", "cmd", "/c", "${file_path}\\\\project & echo. & pause"]
        },
        {
            "name" : "Project Build Only",
            "cmd" : ["g++", "${file_path}\\\\*.cpp", "-std=c++11", "-o", "${file_path}\\\\project"]
        },
        {
            "name" : "Project Run Only",
            "cmd" : ["start", "cmd", "/c", "${file_path}\\\\project & echo. & pause"]
        }
    ]
}
Copy after login

含义讲解

  • CPP : 这个会编译当前文件,并弹出一个cmd命令框(运行这个程序)。
  • 如果是build的那就是只有编译的。
  • 如果是run的那就是只有运行
  • 如果是build&run那就是编译且运行。

Detailed explanation of how sublime builds a C/C++ compilation environment

  • 第一个 CPP : 这个会编译当前文件,并弹出一个cmd命令框(运行这个程序)。
  • 第二个 CPP-Build-Only就是会只编译一下。
  • 第三个CPP-Run-Only就是只运行一下。
  • 第四个CPP-Pipe Build and Run 会在当前代码所在目录找,找到in文件(没有后缀)的内容作为输入,并且,输出给out文件(同样没有后缀
  • 第五个 Pipe Run Only 跟上面的唯一区别,就是不会编译。就只输出而已。
  • 第六个 Project Build & Run 就是将当前目录下的所有cpp文件,然后集合编译为一个文件,并且,输出为project.exe的文件,且执行该文件。
  • 第七个Project Build Only,只编译,不运行。
  • 第八个Project Run Only,只运行,不编译。

The above is the detailed content of Detailed explanation of how sublime builds a C/C++ compilation environment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template