Go从入门到精通——常见报错: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

常见报错: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

一、背景

    • 操作系统:windows 10 专业版
    • Go版本:go version go1.19.4 windows/amd64
    • 开发工具:Visual Studio Code 
    • 开发工具版本:1.75.1

  最近在写一个机器人程序,引用了 https://github.com/go-vgo/robotgo 的包,RUN 时候报错如下:

二、软件包介绍

The heart of the Mingw-w64 project is headers and support libraries to run the output of GCC on Windows. Since Mingw-w64 is neither the home of GCC nor of binutils, several sets of installation packages which combine them are available.

Mingw-w64项目的核心是在 Windows 上运行 GCC 输出的头和支持库。由于 Mingw-w64既不是 GCC 的发源地,也不是 binutils 的发源地,因此可以使用几组组合它们的安装包。

三、造成原因分析

  缺少 gcc 编译器,进行安装

四、解决方案

3.1、下载软件包

  浏览器访问:https://sourceforge.net/projects/mingw-w64/,并下载MinGW-W64-install.exe包。

 

 3.2、开始安装

 

注意:这里需要根据系统是64还是32位进行选择,一般我们的系统都是64位的,改为x86_64即可。

程序安装目录我用默认的目录,你自己可以按照自己的情况。点击 Next ,等待它安装吧。。。

在线安装时候,报错了,可能是外网的问题。

我重新下载免安装版本:x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z,连接地址:https://sourceforge.net/projects/mingw-w64/files/

我下载的软件包下载地址:https://cytranet.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z

将解压后的目录,添加在 windows 的环境变量 PATH 中:

  gcc的报错解决了啦!

 

posted @ 2023-02-25 17:00  左扬  阅读(2608)  评论(0编辑  收藏  举报
levels of contents