首先安装mingw,mingw是gnu在windows下的一个实现,对于我们这个需求,比用cygwin更加合适
官网如下说
MinGW compilers provide access to the functionality of the Microsoft C
runtime and some language-specific runtimes. MinGW, being Minimalist,
does not, and never will, attempt to provide a POSIX runtime
environment for POSIX application deployment on MS-Windows. If you
want POSIX application deployment on this platform, please consider
Cygwin instead.
安装也非常容易 http://www.mingw.org/wiki/Getting_Started
直接去此页面下载,然后安装时选择安装c编译器,当然如果忘记勾选,直接cmd命令行
mingw-get install gcc g++ mingw32-make
都是可以的
将C:\MinGW\bin 加入环境变量然后新建sublime text 2编译规则
{
"cmd": ["gcc","${file}", "-o", "${file_path}/${file_base_name}"],
//"cmd": ["make"],
"file_regex": "^(..[^:]):([0-9]+):?([0-9]+)?:? (.)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["${file_path}/${file_base_name}"]
}
]
}
之后重启sublime text2 就可以了
如果懒得配置可以下载CodeBlocks的集成开发环境,这个自带mingw,直接可以开发了,
不过我还是觉得重量了点,sublime text2配合mingw非常轻量级