cross compile go

http://spf13.com/post/cross-compiling-go/

https://coderwall.com/p/pnfwxg/cross-compiling-golang

安装设置

参考:http://stackoverflow.com/questions/12168873/cross-compile-go-on-osx
可以进入go src目录,然后执行命令(以目标系统是32bit windows为例):

cd /usr/local/go/src
sudo GOOS=windows GOARCH=386 CGO_ENABLED=0 ./make.bash --no-clean

如果是mac,使用homebrew安装的话,可以直接:

$ brew install go --with-cc-common # Linux, Darwin, and Windows
$ brew install go --with-cc-all # All the cross-compilers

如果已经安装过go,可以换成reinstall命令来重新安装。

编译

设置环境变量:
GOARCH - the architecture, e.g. amd64, 386 or arm
GOOS - the operating system - linux, darwin or windows

示例:

$ GOARCH=arm GOOS=linux go build helloworld
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值