问题展示
# runtime/cgo
linux_syscall.c:67:13: error: call to undeclared function 'setresgid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
linux_syscall.c:67:13: note: did you mean 'setregid'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:593:6: note: 'setregid' declared here
linux_syscall.c:73:13: error: call to undeclared function 'setresuid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
linux_syscall.c:73:13: note: did you mean 'setreuid'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:595:6: note: 'setreuid' declared here
问题解决
1、brew下载编译成linux的所需环境
brew install FiloSottile/musl-cross/musl-cross
这一步下载需要使用国内的镜像,我使用的是清华的镜像下载的,下载的过程中会因为一下问题中断,你直接在终端一直重新输入以上命令
2、如果还不行就需要配置go env文章来源:https://www.toymoban.com/news/detail-769235.html
go env -w CC="x86_64-linux-musl-gcc"
go env -w CXX="x86_64-linux-musl-g++"
go env -w GOOS=linux
go env -w GOARCH=amd64
go env -w CGO_ENABLED='0'
这个问题搞了我两天基本上把所有的论坛都找了一个遍,最后通过go官网里面的issue的这个方式解决的。以后有问题还是用谷歌浏览器比较好!文章来源地址https://www.toymoban.com/news/detail-769235.html
到了这里,关于Mac M1 解决Go交叉编译成linux文件报错问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!