cgo: exec gcc: exec: “gcc”: 在 $PATH 中找不到可执行文件。Egress 操作符安装出错。

huangapple go评论99阅读模式
英文:

cgo: exec gcc: exec: "gcc": executable file not found in $PATH Error in Egress operator installation

问题

我正在尝试使用Egress Operator来基于域名限制出站调用。我正在使用Ubuntu 18的Hyper-V虚拟机,并且我已经满足了所有的先决条件

  1. Azure仓库用于推送镜像
  2. 使用Kubebuilder进行代码生成
  3. 使用Kustomize构建Kubernetes清单
  4. 运行CoreDns(k3s默认)的Pod
  5. Golanggo version 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

此外,在编辑了coredns部署和ConfigMap中的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

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

英文:

I am trying Egress Operator for restricting the egress calls based on domain. I am using Ubuntu 18 Hyper-V VM and I have all prerequisites:

  1. Azure repository to push images
  2. Kubebuilder for code generation
  3. Kustomize for building the Kubernetes manifests
  4. CoreDns (default with k3s) pod running
  5. Golang : go version go1.16.5 linux/amd64

But while Testing locally make run is giving below error:

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

Also after editing coredns deployment and coredns Corefile in ConfigMap, as mentioned in coredns plugin setup I am seeing blow error while executing make deploy command:

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

Can someone let me know how to resolve this ?

答案1

得分: 3

看起来你的环境没有安装gcc编译器。请尝试以下步骤:

sudo apt-get install build-essential

或者

sudo apt-get build-dep gcc

然后检查安装是否成功:

gcc --version

还可以参考这个类似的问题

英文:

It looks like your environment doesn't have the gcc compiler installed. Please try this as follows:

sudo apt-get install build-essential

or

sudo apt-get  build-dep  gcc

Then check if the installation is successful:

gcc --version

See also this similar problem.

huangapple
  • 本文由 发表于 2021年7月8日 16:51:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/68298436.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定