Golang Cross-compiling

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

GOOS and Goarch reference for each platform

OS ARCH OS Version

Linux 386/amd64/arm >= Linux 2.6

Darwin 386/amd64 OS X (Snow Leopard + Lion)

FreeBSD 386/amd64 >= FreeBSD 7

Windows 386/AMD64 >= Windows 2000

$ cd/usr/local/go/src
$ sudo cgo_enabled=0 goos=linux goarch=amd64./make.bash

This is not to recompile go, because when you install go, you just compile what your local system needs, and cross-platform compilation requires more support for other platforms in go. So, there is./make.bash such a process.

The execution results are similar to the following:

sudo cgo_enabled=0 goos=linux goarch=amd64./make.bash
Password:

Building C Bootstrap tool.

Cmd/dist

Building compilers and Go bootstrap tool for host, Darwin/amd64.

Lib9
Libbio
Libmach
Misc/pprof
Cmd/addr2line
Cmd/cov
Cmd/nm
Cmd/objdump
Cmd/pack
Cmd/prof
cmd/cc
......
Pkg/text/template/parse
Pkg/text/template
Pkg/go/doc
Pkg/go/build
Cmd/go
Pkg/runtime (LINUX/AMD64)

Building packages and commands for host, Darwin/amd64.

Runtime
Errors
Sync/atomic
Unicode
Unicode/utf8
Math
Sync
Unicode/utf16
Crypto/subtle
Io
Syscall
..........
Net/rpc/jsonrpc
Testing/iotest
Testing/quick

Building packages and commands for LINUX/AMD64.

Runtime
Errors
Sync/atomic
Unicode
Unicode/utf8
Math
Sync
Unicode/utf16
........
Testing
Net/rpc/jsonrpc
Testing/iotest
Testing/quick

Installed Go for LINUX/AMD64 In/usr/local/go
Installed Commands In/usr/local/go/bin

Third, compile the executable file under the corresponding platform
To the source code directory to execute:

Cgo_enabled=0 goos=linux goarch=amd64 Go build sina.go

Go build without the preceding parameters simply compiles the executable file that the development environment applies to.

Originally from: http://m.oschina.net/blog/131480

Related Article

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.