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

Posted Charles Yan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cgo: C compiler “gcc“ not found: exec: “gcc“: executable file not found in %PATH%相关的知识,希望对你有一定的参考价值。

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

问题描述

  • 场景描述

    win10系统搭建的golang开发环境,版本是go version go1.17.2 windows/amd64,采用gongland作为开发工具,编写的main.go文件,执行main方法时报错,采用命令执行也是同样问题

  • 报错信息

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

原因分析

  • 缺少gcc编译器

    简单执行fmt方法时正常,后来由于引入的新的包,导致需要c语言编译环境,而系统缺少相关安装环境,所以执行失败。

解决方案

  • 下载MinGW-w64安装包并配置系统环境变量

    官网地址:https://sourceforge.net/projects/mingw-w64/files/

参考链接

  • Windows环境golang程序开发 报错exec: gcc: executable file not found in %PATH%

    https://blog.csdn.net/Lyon_Nee/article/details/106840502

  • MinGW-w64 离线包安装方法

    https://blog.csdn.net/weixin_36466834/article/details/119569365

以上是关于cgo: C compiler “gcc“ not found: exec: “gcc“: executable file not found in %PATH%的主要内容,如果未能解决你的问题,请参考以下文章

Nginx部署.nginx报错:./configure: error: C compiler cc is not found, gcc 是已经安装了的

./libtool --mode=compile gcc -O2 -I. -c ./jcapimin.c make: ./libtool: Command not found

./configure: error: C compiler cc is not found

nginx安装错误:c compiler cc is not found

CGO基础

CGO基础