---
title: "sublime编译运行C程序"
author: "Perrin Yong"
author_profile: https://www.pystone.net/profile/
published_by: "Perrin Yong"
canonical: https://www.pystone.net/notes/sublime-compile-run-c/
type: note
content_role: unspecified
visibility: public
id_stability: rename-stable
source_path: "10-计算机、信息技术与工程/02-编程语言与运行时/C++/sublime编译运行C程序.md"
content_hash: 63bdb959192886d88bac0d4b6a6e777f664efff4216ce3b0481bcb1b8535b64b
knowledge_version: 224c990773de.5fa8af6e39fa
site_commit: 224c990773de166d23a886306577dd90379529ce
notes_commit: 5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a
---
# sublime编译运行C程序

﻿# sublime编译运行C程序

> 创建时间：2020/10/6 23:28

### MinGW环境配置

> MinGW64网盘下载
>  链接：https://pan.baidu.com/s/15WXjNrMAQl2ffIfqMj3lqg
>  提取码：uigv

  * 变量名 变量值
  * C_INCLUDEDE_PATH C:\MinGW64\include
  * LIBRARY_PATH C:\MinGW64\lib
  * Path C:\MinGW64\bin

### Sublime设置

#### 基本的C语言编译

Tools -> Build System -> New Build System
配置内容：

```cpp
string str1 = &quot;test&quot;;
string str2 = &quot;test&quot;;

```

保存配置文件名称为 `C.sublime-bulld`

Tools -> Build System -> C

按Ctrl+Shfit+B按钮，选择“C - Run”

#### CPP编译配置

若MinGW中没有安装g++，则

```cpp
string str1 = &quot;test&quot;;
string str2 = &quot;test&quot;;

```

说明:

  * 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，只运行，不编译。

### 一些问题

解决不能编译for语句 （-std=c99）
解决C语言输出中文是乱码 （-fexec-charset=gbk）

### Ref

https://zhuanlan.zhihu.com/p/215841527
https://blog.csdn.net/a19990412/article/details/82658981
