Go Cross Compilation

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Specify Fork Compilation target:
Goarch processor architecture for Target platform (compiled target platform) (386, AMD64, ARM)
Operating system for GOOS target platform (compiled target platform) (Darwin, FreeBSD, Linux, Windows)

(i) Linux 64-bit executable program under Windows compilation:

    SET CGO_ENABLED=0  //不设置也可以,原因不明    SET GOOS=linux    SET GOARCH=amd64    通过 go env 查看设置是否成功。

(ii) Linux compiled Windows executable program:

    export CGO_ENABLED=0    export GOOS=windows    export GOARCH=amd64    通过 go env 查看设置是否成功。    go build hello.go

Reference: http://blog.csdn.net/panshiqu/article/details/53788067

Problem:
The above (one) method setting can only take effect in the current window, and then search out other methods, but unsuccessful.

SET CGO_ENABLED=0 SET GOOS=linuxSET GOARCH=amd64make.bat

Error:

Solve:
Set the environment variable GOROOT_BOOTSTRAP to the Go installation directory C:\Go

Run Make.bat Error again:

GitHub has explained that: not the source code compiled to install the go, re-source installation go can solve

Problem:
$ go Get github.com/gorilla/websocket
Error:
As shown in the Make.bat
Solve:
Reinstall Go,https://storage.googleapis.com/golang/go1.8.3.windows-amd64.zip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.