加入收藏 | 设为首页 | 会员中心 | 我要投稿 拼字网 - 核心网 (https://www.hexinwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

使用OS X上的cgo到linux和windows进行1.5交叉编译

发布时间:2020-12-25 15:30:52 所属栏目:Linux 来源:网络整理
导读:在将1.4.2升级到1.5后,我无法将OS X上的 git2go 库编译为linux amd64. 我认为这是关于交叉编译任何使用C代码和go 1.5的应用程序. 使用CGO_ENABLED = 1,我得到: $CGO_ENABLED=1 GOOS=linux GOARCH=amd64 ./script/with-static.sh go install ./...# runtime/

在将1.4.2升级到1.5后,我无法将OS X上的 git2go库编译为linux amd64.

我认为这是关于交叉编译任何使用C代码和go 1.5的应用程序.

使用CGO_ENABLED = 1,我得到:

$CGO_ENABLED=1 GOOS=linux GOARCH=amd64 ./script/with-static.sh go install ./...
# runtime/cgo
ld: unknown option: --build-id=none
clang: error: linker command failed with exit code 1 (use -v to see invocation)

使用-compiler = gccgo,我得到:

$GOOS=linux GOARCH=amd64 ./script/with-static.sh go install -compiler gccgo ./...
go build github.com/libgit2/git2go: : fork/exec : no such file or directory

如果没有提供任何这些,我得到:

$GOOS=linux GOARCH=amd64 ./script/with-static.sh go install ./...
can't load package: package github.com/libgit2/git2go: C source files not allowed when not using cgo or SWIG: wrapper.c

我用自制软件安装了,我有$GOPATH指向默认的?/ go位置,没什么特别的.

解决方法

交叉编译时,默认情况下不启用cgo.如果启用cgo,CGO_ENABLED = 1,则需要为目标机器交叉编译c编译器.这不是一件轻而易举的事.

如果你需要cgo,我建议你本地编译.

(编辑:拼字网 - 核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!