在将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,我建议你本地编译.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。