search
HomeDevelopment ToolssublimeAn article explains how to configure the c compilation environment and test sublime text3

下面由sublime教程栏目给大家介绍sublime text3怎么配置c编译环境,希望对需要的朋友有所帮助!

  • 软件下载可以在官网下载,均为免费软件
  • sublime text3虽然收费但是支持无限期试用且功能不受限制(免费软件)

使用sublime text3编译c语言部分


准备工作

  • 下载sublime text3
  • 配置计算机c语言编译环境,下载MinGW即可
  • 配置MinGW的系统变量
    • 将下载解压的MinGW的bin文件路径写进系统的path路径下。 下面有教程!
  • 配置sublime text3c语言编译环境

配置环境变量

  • 为了方便,一般我们会把gcc所在的路径加入系统的环境变量,这样就可以直接使用gcc命令而不用绝对路径。右键计算机->属性->高级系统设置->环境变量

  • 在path的值中,可以发现有一些目录,他们之间用英文的分号分隔。我们双击path,把我们gcc的路径 C:\MinGW\bin 添加进去。 要注意前后的英文分号。

  • 确定以后 就可以在任意目录下直接使用gcc命令了。可以在任意目录打开cmd窗口,输入gcc - v查看环境变量是否设置成功。如果仍然提示不是内部或外部命令,说明环境变量设置失败。

  • 如果失败,请重新配置环境变量!这一步至关重要,新手很容易卡在这一步!

新建sublime text3的c语言编译环境

  1. 第一步,打开sublime text3 选择 中文版:工具>>编译系统>>新建编译系统 英文版:tool –> Build System –> New Build System
  1. 输入下面代码保存
{"shell_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","shell_cmd":"g++
 \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""}


]


}
  • 按Ctrl+s保存,会自动打开user目录(Sublime Text 3\Packages\User),我们修改 文件名为 c.sublime-build,保存在此目录。
    • 保存之后,可以在Tools -> Build System下看到刚才新建的c了(工具->编译系统)
      至此,已经配置完了所有环境,只需要写入代码即可运行,下来我们一起写一个简单的程序测试一下

  1. 首先写上一段c代码进sublime text3
#include<stdio.h>	\\经典的c语言入门程序int main(void)
{	
printf("hell\n");return 0;
}

2. 然后选择编译环境 选择工具>>编译系统>>选择c即可

3.写完代码按下快捷键:Ctrl+Shift+B

4.第一行中c就是对应执行配置文件中的第三行 gcc -Wall $file_name -o $file_base_name作用是编译。

第二行的c-Run对应后面的命令 gcc -Wall $file -o $file_base_name && start cmd /c \”${file_path}/${file_base_name} & pause\”,作用是是在新的cmd窗口运行。这样就可以对scanf等函数进行输入了。

5.我们选择第二行c-Run

6.完美运行。

更多sublime相关知识,请访问sublime教程栏目:https://www.php.cn/tool/sublime/

The above is the detailed content of An article explains how to configure the c compilation environment and test sublime text3. 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
Sublime Text vs. VS Code: Features and FunctionalitySublime Text vs. VS Code: Features and FunctionalityMay 11, 2025 am 12:20 AM

SublimeText is suitable for developers who pursue speed and simplicity, while VSCode is suitable for users who need strong scalability and integration capabilities. 1.SublimeText is known for its lightweight and fast response, with GotoAnything and multi-select powerful. 2. VSCode is known for its scalability and IDE functions, with built-in Git and debugging tools, and IntelliSense improves development efficiency.

Sublime Text: The Power of Plugins and PackagesSublime Text: The Power of Plugins and PackagesMay 10, 2025 am 12:17 AM

SublimeText's plug-ins and packages can be installed and managed through PackageControl to improve programming efficiency. 1. Install plug-ins such as BracketHighlighter to simplify code reading by highlighting bracket matching. 2. Use SublimeLinter to configure pylint to implement real-time code checking. 3. Use SideBarEnhancements to customize the sidebar function to optimize file management.

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.

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 Article

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.