MinGW分为较早开发的MinGW32和之后为编译64位程序开发的MinGW-w64,MinGW32只能编译32位的程序,而mingw64不仅能编译64位程序,也能编译32位程序,还能进行交叉编译,即在32位主机上编译64位程序,在64位主机上编译32位程序。

    由于用的window10 企业版64位操作系统,

exec: "gcc": executable file not found in %PATH%_环境变量



下载地址:https://pan.baidu.com/s/1RNvMBXUiHXruXzrGySnQRg

exec: "gcc": executable file not found in %PATH%_安装包_02


 点击“Download”按钮,

exec: "gcc": executable file not found in %PATH%_环境变量_03

 在使用mingw64之前,由于其支持较多的编译类型,所以其安装包较多,需要了解其安装包的命名规则:​​http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure​

    一般采用personal文件夹下的两个版本的包编译64位程序:​​https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/​

exec: "gcc": executable file not found in %PATH%_环境变量_04

exec: "gcc": executable file not found in %PATH%_环境变量_05
657·240

    threads-win32是编译目标程序是32位,threads-posix是编译目标程序是64位

下载mingw-w64-install.exe之后进行安装(离线安装,比较慢,可以):

exec: "gcc": executable file not found in %PATH%_环境变量_06

     根据系统环境,选择相关配置:

exec: "gcc": executable file not found in %PATH%_环境变量_07

    选择安装路径:

exec: "gcc": executable file not found in %PATH%_.net_08

exec: "gcc": executable file not found in %PATH%_.net_09

    下载比较慢,耐心等待……

exec: "gcc": executable file not found in %PATH%_环境变量_10

exec: "gcc": executable file not found in %PATH%_环境变量_11
561·418

exec: "gcc": executable file not found in %PATH%_环境变量_12

exec: "gcc": executable file not found in %PATH%_环境变量_13

exec: "gcc": executable file not found in %PATH%_环境变量_14
561·418

    这个安装过程是在折磨人,可以下载对应的压缩包。

 在cmd下,打开C:\mingw-w64\i686-6.2.0-posix-dwarf-rt_v5-rev1\mingw32\bin目录,输入gcc -v,出现如下图,说明安装成功:

exec: "gcc": executable file not found in %PATH%_环境变量_15


安装成功后,如何让go编译器调用gcc呢?需要设置环境变量path,如下添加C:\mingw64\bin到path环境变量值下:

exec: "gcc": executable file not found in %PATH%_安装包_16

    再次编译go语言,问题已解决~~~~