问题描述

使用sublime text3编译go语言时,出现以下问题:

  1. exec: "gcc": executable file not found in %PATH%
  2. exit status 2

解决方案

下载mingw64

  1. 下载地址[:https://sourceforge.net/projects/mingw-w64/](https://sourceforge.net/projects/mingw-w64/)<br />![](https://cdn.nlark.com/yuque/0/2018/png/200878/1543412748432-6ecbed9f-b782-4a1d-9d17-562dc80036be.png#width=827)<br />点击"Download"按钮:<br />![](https://cdn.nlark.com/yuque/0/2018/png/200878/1543412764414-1f8bd379-fb64-4fa4-abb8-d278cd2de404.png#width=827)

安装

下载mingw-w64-install.exe执行安装(离线按钮,比较慢):
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图1

根据系统环境,选择相关配置:
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图2
选择安装路径
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图3
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图4

下载比较慢,耐心等待…
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图5
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图6调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图7

环境测试

在cmd下,打开安装路径下的&{installdir}\mingw-w64\i686-6.2.0-posix-dwarf-rt_v5-rev1\mingw32\bin目录下,输入gcc -v, 出现如下图,说明安装成功
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图8

通过压缩包安装

  1. 下载压缩包,解压到指定的目录下,如下图:<br />![](https://cdn.nlark.com/yuque/0/2018/png/200878/1543412935101-ef5f0e39-a534-4b9c-87d1-eff1384ecf16.png#width=827)

在cmd下,打开安装路径下的&{installdir}\mingw-w64\i686-6.2.0-posix-dwarf-rt_v5-rev1\mingw32\bin目录下,输入gcc -v, 出现如下图:
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图9

应用测试

安装成功后,如何让go编译器调用gcc呢?需要设置系统环境变量path,如下添加C:\mingw64\bin到path环境变量值下:
调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图10
再次编译go语言,问题解决~~.


调试go语言出现:exec: "gcc": executable file not found in %PATH% - 图11