第一步 下载MinGW

链接:http://pan.baidu.com/s/1boWp7FT 密码:peh1
在C盘根目录下新建一个MinGW文件夹,将下载完的压缩包解压到该文件夹下


第二步 添加系统环境变量
在桌面上新建文本文档,取名为“添加环境变量.dat”,如下图

在文本内添加下列代码(添加完切记按保存):
wmic ENVIRONMENT where "name='path' and username=''" set VariableValue="%path%;C:\MinGW\bin"
wmic ENVIRONMENT create name="LIBRARY_PATH",username="",VariableValue="C:\MinGW\lib"
wmic ENVIRONMENT create name="C_INCLUDEDE_PATH",username="",VariableValue="C:\MinGW\include"
保存之后,点右键“管理员取得所有权”,会自动运行,添加环境变量完成
下一步:

在path的值中,可以发现有一些目录,他们之间用英文的分号分隔。我们双击path,把我们gcc的路径 C:\MinGW\bin 添加进去。 要注意前后的英文分号。
第三步 下载sublime text 3并新建C语言编译系统
链接:http://pan.baidu.com/s/1qXEomOO 密码:oxts
下载完直接解压即可,找到解压文件,将应用程序直接以桌面快捷方式发送到桌面,方便后续使用

新建C语言编译系统
选择tool –> Build System –> New Build System

将弹出界面清空,输入下列代码:
{
"working_dir": "$file_path",
"cmd": "gcc -Wall \"$file_name\" -o \"$file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c",
"variants":
[
{
"name": "Run",
"shell_cmd": "gcc -Wall \"$file\" -o \"$file_base_name\" && start cmd /c \"${file_path}/${file_base_name} & pause\""
}
]
}
按Ctrl+s保存,会自动打开user目录(Sublime Text 3\Packages\User),我们修改 文件名为 c.sublime-build,保存在此目录。

修改 文件名为 c.sublime-build
这时候,可以在Tools -> Build System下看到刚才新建的c了
选中后就可以使用了。

这样子整个就安装完成了
第四步 如何编写程序并编译运行
首先 在E盘新建文件夹,命名为code(不要以中文命名,会出错)

将所有写的程序整理到一个文件夹是一个好习惯
打开sublime text,新建一个new file,ctrl+s保存之后“code”文件夹下边任意一个分组里,
code里的文件夹,用于将不同的项目代码区分开,需要自己建立

因为编写为C语言,后缀名为.c(切记)

测试代码
点击 Tools ->Build with,皆可编译
网友评论