search
HomeDevelopment ToolssublimeDetailed explanation of how sublime builds a C/C++ compilation environment

下面由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"]
        }
    ]
}

含义讲解

  • 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!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
Is Sublime Text Free? Understanding the LicensingIs Sublime Text Free? Understanding the LicensingMay 09, 2025 am 12:10 AM

SublimeTextisfreeduringanunlimitedtrial,buta$99licenseisrecommendedforregularuse.1)Thetrialallowsfullfeatureaccesswithouttimelimits.2)Alicenseoffersperpetualuse,futureupdates,andremovespurchasereminders,enhancingproductivityandsupportingdevelopers.

Sublime Text: Enhancing Your Coding WorkflowSublime Text: Enhancing Your Coding WorkflowMay 08, 2025 am 12:19 AM

SublimeText can greatly improve work efficiency. 1) Multiple selection and multicursor functions allow editing of multiple positions at the same time, 2) Command panel provides fast function access, 3) Macros and fragments can automate common operations, 4) Optimized configuration and shortcut key use can improve performance and efficiency.

Sublime Text: Free to Try, Not Necessarily Free to OwnSublime Text: Free to Try, Not Necessarily Free to OwnMay 07, 2025 am 12:02 AM

SublimeText offers a free trial, but ultimately requires a paid purchase for a permanent authorization. 1) During the free trial period, users can experience its functions, but they will receive a purchase prompt. 2) After purchase, users can use it permanently, no subscription fee, and access more plug-ins and themes.

Sublime Text: Comparing Paid and Unpaid FeaturesSublime Text: Comparing Paid and Unpaid FeaturesMay 06, 2025 am 12:07 AM

ThemaindifferencesbetweenthepaidandunpaidversionsofSublimeTextaretheremovalofstatusbarremindersandoccasionalpop-uppromptsinthepaidversion.1)Unregisteredversion:fullyfunctionalwithallcorefeatureslikesyntaxhighlighting,codecompletion,andcommandpalette,

Sublime Text: The Cost of a Powerful EditorSublime Text: The Cost of a Powerful EditorMay 05, 2025 am 12:04 AM

SublimeText is worth buying. 1) Its simple interface and powerful functions, such as multi-line editing and GotoAnything, improve development efficiency. 2) Rich plug-in ecosystem, such as Anaconda, enhances the development experience. 3) Although the price is $70, its performance and fluency are great value for professional developers.

Sublime Text: Code Completion, Syntax Highlighting, and MoreSublime Text: Code Completion, Syntax Highlighting, and MoreMay 04, 2025 am 12:04 AM

SublimeText is loved by developers for its powerful code completion and syntax highlighting capabilities. 1) Code completion can automatically prompt function names, variable names, etc. to improve programming efficiency. 2) Syntax highlighting distinguishes code elements through different colors to improve readability and error detection speed.

Sublime Text vs. VS Code: A Comparative AnalysisSublime Text vs. VS Code: A Comparative AnalysisMay 03, 2025 am 12:07 AM

SublimeTextisidealforthosevaluingspeedandsimplicity,whileVSCodesuitsthoseneedingextensivefeaturesandcustomization.SublimeTextoffersquickfileaccesswith"GotoAnything"andaminimalisticapproach,butmaylackout-of-the-boxfunctionality.VSCodeprovide

Sublime Text: Your Coding CompanionSublime Text: Your Coding CompanionMay 02, 2025 am 12:01 AM

SublimeTextisapowerfulcodingcompanionduetoitsspeed,customization,andkeyfeatures.1)Itoffersincrediblespeedforhandlinglargefiles.2)Itsflexibilityallowsextensivecustomizationwithpluginsandthemes.3)Featureslikemultiplecursors,GotoAnything,CommandPalette,

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version