mingw-w64

1 下载

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

2 安装

2.1 双击打开安装程序

在win10下安装ubuntu18.04子系统(超详细windows安装配置WSL2)(1)

2.2 选择完成之后即可开始安装

在win10下安装ubuntu18.04子系统(超详细windows安装配置WSL2)(2)

3 配置环境变量

3.1 我的电脑——属性——高级系统设置——环境变量选择系统变量中的path单击编辑

在win10下安装ubuntu18.04子系统(超详细windows安装配置WSL2)(3)

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检查是否安装成功

在win10下安装ubuntu18.04子系统(超详细windows安装配置WSL2)(4)

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

  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; }

,