登录
首页 >  Golang >  Go问答

解决mac m1上gcc执行状态1错误的方法

来源:stackoverflow

时间:2024-03-10 08:00:30 128浏览 收藏

最近发现不少小伙伴都对Golang很感兴趣,所以今天继续给大家介绍Golang相关的知识,本文《解决mac m1上gcc执行状态1错误的方法》主要内容涉及到等等知识点,希望能帮到你!当然如果阅读本文时存在不同想法,可以在评论中表达,但是请勿使用过激的措辞~

问题内容

我已经安装了 mingw-w64。 当我检查版本时,它就在那里。

gcc --版本:

gcc(自制 gcc 11.2.0_3)11.2.0

g++ --版本:

g++(自制gcc 11.2.0_3)11.2.0

我还运行which gcc:

/opt/homebrew/bin/gcc

然后我使用图像 golang:latest 运行 docker-compose。还没有错误

up to date, audited 370 packages in 10m

9 packages are looking for funding
  run `npm fund` for details

6 high severity vulnerabilities

to address issues that do not require attention, run:
  npm audit fix

to address all issues (including breaking changes), run:
  npm audit fix --force

run `npm audit` for details.
unlinking stale socket /tmp/supervisor.sock
[15:30:39] using gulpfile /go/src/github.com/projectname/src/api/gulpfile.js
[15:30:39] starting 'default'...
[15:30:39] starting 'watch'...

当我保存 .go 文件时,它会下载所有 mod,这就是错误:

# github.com/projectname/api
 /usr/local/go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
 collect2: fatal error: cannot find 'ld'
 compilation terminated.

 [15:46:23] 'build-binary' errored after 1.98 s
 [15:46:23] error in plugin "gulp-shell"
 message:
     command `go build` failed with exit code 2

这是我的 dockerfile

FROM golang:1.17.0-alpine3.14 AS builder
    
RUN apk update && apk add gcc make git libc-dev binutils-gold

# Install dependencies
RUN apk add --update tzdata \
    --no-cache ca-certificates git wget \
    nodejs npm \
    g++ \
    supervisor \
    && update-ca-certificates \
    && npm install -g gulp gulp-shell
RUN npm install -g yarn


COPY ops/api/local/supervisor /etc
ENV PATH $PATH:/go/bin
WORKDIR /go/src/github.com/projectname/src/api

正确答案


尝试检查添加 binutils-gold 是否允许您使用 ld(如 in this Dockerfile)。

RUN apk update && apk add gcc make git libc-dev binutils-gold

(首次出现于 nodejs/node issue 4212

终于介绍完啦!小伙伴们,这篇关于《解决mac m1上gcc执行状态1错误的方法》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布Golang相关知识,快来关注吧!

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