1 下载
下载链接为https://sourceforge.net/projects/mingw-w64/
2 安装
2.1 双击打开安装程序
- Version:gcc版本,选择最高的即可
- Architecture:64位选择x86_64,32位电脑选择i686
- Threads:操作系统接口协议,开发windows程序选择win32
- Exception:异常处理模型一般选择较新的seh
- Build revision
2.2 选择完成之后即可开始安装
3 配置环境变量
3.1 我的电脑——属性——高级系统设置——环境变量选择系统变量中的path单击编辑
3.2 将Mingw-w64的安装路径加入path中,我这里安装路径是C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-\rev0\mingw64\bin
4 测试
win r打开cmd输入gcc -v检查是否安装成功
sublime text
1 配置C
1.1 打开sublime text
1.2 Tool——Build System——New Build System
1.3 填入以下代码,保存命令为C.sublime-build
{
"cmd": ["gcc","-Wall", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9] ):?([0-9] )?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c ",
"encoding":"cp936",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/c", "gcc", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "cmd", "/c", "${file_path}/${file_base_name}"]
},
{
"name": "RunInCommand",
"cmd": ["cmd", "/c", "gcc", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"]
},
{
"name": "RunInShell",
"shell_cmd": " start cmd /c \"\"${file_path}/${file_base_name}\"&pause\" "
}
]
}
配置C
- 打开sublime text
- Tool——Build System——New Build System
- 填入以下代码,保存命令为C .sublime-build
{
"cmd": ["g ","-Wall", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9] ):?([0-9] )?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c ",
"encoding":"cp936",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/c", "g ", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "cmd", "/c", "${file_path}/${file_base_name}"]
},
{
"name": "RunInCommand",
"cmd": ["cmd", "/c", "g ", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"]
},
{
"name": "RunInShell",
"shell_cmd": " start cmd /c \"\"${file_path}/${file_base_name}\"&pause\" "
}
]
}
测试
输出hello world成功
#include<iostream>
using namespace std;
int main()
{
cout<<"hello world!";
return 0;
}