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%,第1张

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/989602.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存