sublime text与mingw-w64配置C/C++编译环境

mingw-w64

下载

下载链接为https://sourceforge.net/projects/mingw-w64/

安装

1.双击打开安装程序
在这里插入图片描述

  • Version:gcc版本,选择最高的即可
  • Architecture:64位选择x86_64,32位电脑选择i686
  • Threads:操作系统接口协议,开发windows程序选择win32
  • Exception:异常处理模型一般选择较新的seh
  • Build revision

2.选择完成之后即可开始安装
在这里插入图片描述

配置环境变量

  1. 我的电脑——属性——高级系统设置——环境变量选择系统变量中的path单击编辑
    在这里插入图片描述
  2. 将Mingw-w64的安装路径加入path中,我这里安装路径是C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-\rev0\mingw64\bin

测试

win+r打开cmd输入gcc -v检查是否安装成功
在这里插入图片描述

sublime text

配置C

  1. 打开sublime text
  2. Tool——Build System——New Build System
  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++

  1. 打开sublime text
  2. Tool——Build System——New Build System
  3. 填入以下代码,保存命令为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;
}
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值