登录
首页 >  Golang >  Go问答

Egress 操作器安装时遇到错误:cgo: exec gcc: exec: "gcc": 找不到可执行文件于 $PATH

来源:stackoverflow

时间:2024-03-05 14:36:27 311浏览 收藏

来到golang学习网的大家,相信都是编程学习爱好者,希望在这里学习Golang相关编程知识。下面本篇文章就来带大家聊聊《Egress 操作器安装时遇到错误:cgo: exec gcc: exec: "gcc": 找不到可执行文件于 $PATH》,介绍一下,希望对大家的知识积累有所帮助,助力实战开发!

问题内容

我正在尝试出口操作员来限制基于域的出口呼叫。我正在使用 ubuntu 18 hyper-v vm,并且满足所有先决条件:

  1. 用于推送图像的 azure 存储库
  2. kubebuilder 用于代码生成
  3. kustomize,用于构建 kubernetes 清单
  4. coredns(默认使用 k3s)pod 正在运行
  5. golanggo 版本 go1.16.5 linux/amd64

但是在本地测试 make run 时给出以下错误:

root@ubuntu18-virtual-machine:~/egress-operator# make run
go: creating new go.mod: module tmp
go get: added sigs.k8s.io/controller-tools v0.2.4
/root/go/bin/controller-gen object:headerfile=./hack/boilerplate.go.txt paths="./..."
error: go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags ignore_autogenerated -- ./...]: exit status 2: # runtime/cgo
cgo: exec gcc: exec: "gcc": executable file not found in $path

此外,在 configmap 中编辑 coredns 部署和 coredns corefile 后,如 coredns 插件设置中所述,我在执行 make deploy 命令时看到错误:

root@Ubuntu18-Virtual-Machine:~/egress-operator# make deploy IMG=MY_REPO/egress-operator:v0.1
go: creating new go.mod: module tmp
go get: added sigs.k8s.io/controller-tools v0.2.4
/root/go/bin/controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
Error: go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags ignore_autogenerated -- ./...]: exit status 2: # runtime/cgo
cgo: exec gcc: exec: "gcc": executable file not found in $PATH

有人可以告诉我如何解决这个问题吗?


正确答案


您的环境似乎没有安装 gcc 编译器。请尝试如下操作:

sudo apt-get install build-essential

sudo apt-get  build-dep  gcc

然后检查是否安装成功:

gcc --version

另请参阅此 similar problem

文中关于的知识介绍,希望对你的学习有所帮助!若是受益匪浅,那就动动鼠标收藏这篇《Egress 操作器安装时遇到错误:cgo: exec gcc: exec: "gcc": 找不到可执行文件于 $PATH》文章吧,也可关注golang学习网公众号了解相关技术文章。

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>