情景设定:
操作系统:window7x64
安装目录:c:/go
设置环境变量:
PATH=%PATH%;C:/go/bin
GOROOT= C:/go
GOPATH = D:/goproject
进行交叉编译的原理是设置GOARCH(cpu架构)和GOOS(操作系统)
然后执行c:/go/src/make.bat --no-clean
将c:/go/src的源码编译成各个ARCH下对应OS的包
打包好的批处理文件如下:
set CGO_ENABLED=0 ::x86 set GOARCH=386 set GOOS=windows call make.bat --no-clean set GOOS=linux call make.bat --no-clean set GOOS=freebsd call make.bat --no-clean set GOOS=darwin call make.bat --no-clean :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::x64 set GOARCH=amd64 set GOOS=windows call make.bat --no-clean set GOOS=linux call make.bat --no-clean set GOOS=freebsd call make.bat --no-clean set GOOS=darwin call make.bat --no-clean :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::arm set GOARCH=arm set GOOS=linux call make.bat --no-clean :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: set GOARCH=386 set GOOS=windows pause
将此脚本命令为 cc.bat 放在c:/go/src目录下面执行
执行完成之后,查看下面目录
c:/go/pkg
c:/go/bin
如此之后就可以在liteide里面
进行交叉编译了
有疑问加站长微信联系(非本文作者)