cgo: C compiler “gcc“ not found: exec: “gcc“: executable file not found in %PATH%

问题描述

在执行go run/go build的时候报错:

cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

原因分析

缺少gcc编译器

解决方案

  1. 下载最新离线安装包
    下图示例最新的是8.1.0,下载x86_64-win32-seh
    cgo: C compiler “gcc“ not found: exec: “gcc“: executable file not found in %PATH%_第1张图片

  2. 解压到C盘:
    cgo: C compiler “gcc“ not found: exec: “gcc“: executable file not found in %PATH%_第2张图片

  3. 添加环境变量
    cgo: C compiler “gcc“ not found: exec: “gcc“: executable file not found in %PATH%_第3张图片

  4. 验证是否安装成功
    cgo: C compiler “gcc“ not found: exec: “gcc“: executable file not found in %PATH%_第4张图片

如上图所示即代表已经安装成功

你可能感兴趣的:(GoLang,golang)