MENU

[Golang] cgo: C compiler "gcc" not found

October 28, 2021 • Read: 6230 • 随心笔记

今天从Github拉取了一份代码,结果一编译就出现了以下错误:

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

解决方法:

  1. 下载符合自己系统版本的压缩包,https://sourceforge.net/projects/mingw-w64/files/mingw-w64/

操作系统:windows10 64位 , 下载这个版本
QQ截图20211028114320.png

  1. 压缩包解压之后得到一个mingw64文件夹,直接将整个文件夹复制放入以下路径C:\Program Files (x86)\
  2. 将路径C:\Program Files (x86)\mingw64\bin 加入系统和用户环境变量Path
    PATH.png
  3. 重新打开CMD窗口,输入gcc -v,如果能正确看到版本号,说明安装成功。

参考文章:https://blog.51cto.com/u_15274085/2918704

Leave a Comment

已有 1 条评论
  1. Why am I getting the error "cgo: C compiler 'gcc' not found" when trying to compile a Golang program?