原文来源于:https://www.yii666.com/article/273735.html
go build
Gox 项目地址:https://github.com/mitchellh/gox
安装
go get
$ go get github.com/mitchellh/gox
...
$ gox -h
...
用法
在你使用 Gox 之前,你必须先有一套交叉编译工具链。Gox 可以自动帮你完成这个。你需要做的只是运行(每次更新 Go 都要这样做这步):网址:yii666.com<
$ gox -build-toolchain ...文章来源地址:https://www.yii666.com/article/273735.html
go buildgox
$ gox Number of parallel builds: 4文章来源地址https://www.yii666.com/article/273735.html文章地址https://www.yii666.com/article/273735.html
--> darwin/386: github.com/mitchellh/gox
--> darwin/amd64: github.com/mitchellh/gox
--> linux/386: github.com/mitchellh/gox
--> linux/amd64: github.com/mitchellh/gox
--> linux/arm: github.com/mitchellh/gox
--> freebsd/386: github.com/mitchellh/gox
--> freebsd/amd64: github.com/mitchellh/gox
--> openbsd/386: github.com/mitchellh/gox
--> openbsd/amd64: github.com/mitchellh/gox
--> windows/386: github.com/mitchellh/gox
--> windows/amd64: github.com/mitchellh/gox
--> freebsd/arm: github.com/mitchellh/gox
--> netbsd/386: github.com/mitchellh/gox
--> netbsd/amd64: github.com/mitchellh/gox
--> netbsd/arm: github.com/mitchellh/gox
--> plan9/386: github.com/mitchellh/gox
或者,你只想编译某个项目和子项目:
$ gox ./... ...
或者,你想仅仅为 linux 编译:
$ gox -os="linux" ...
或者,你仅仅只想为 64 位的 linux 编译:
$ gox -osarch="linux/amd64" ...
gox -h
和其他交叉编译工具的比较
非常感谢这些工具为我们提供了更多的选择,它们为 go 平台的交叉编译工具提供做了很多方面的贡献.
- Dave Cheney的交叉编译器: Gox 可以为多种平台编译,所以也能容易地运行在各种 Go 支持的平台上。但Dave的那个需要一个 shell 来运行。Gox 支持并行地编译,但 Dave 的只是按顺序地编译。Gox 也能非常方便地使用的内置的 arch 系统的内置过滤工具。
- goxc:它是一个功能丰富的工具,能编译系统项目,上传二进制文件,产生下载页面等;相较之下,Gox 在交叉编译二元文件方面稍稍弱些。但 Gox 能并行地编译项目,而 goxc 不能。Gox 也没有强制指定编译二元文件时输出结果的格式。
参考资料:
ubuntu 下 golang 跨平台编译 windows 程序: http://studygolang.com/articles/8167
跨平台编译Go程序(交叉编译): http://studygolang.com/topics/21
golang交叉编译: http://blog.csdn.net/coroutines/article/details/39546491
Gox : 简单实在的Go平台交叉编译工具: https://segmentfault.com/a/1190000000346086网址:yii666.com