A dead simple, no frills Go cross compile tool

Related tags

DevOps Tools gox

Gox - Simple Go Cross Compilation

Gox is a simple, no-frills tool for Go cross compilation that behaves a lot like standard go build. Gox will parallelize builds for multiple platforms. Gox will also build the cross-compilation toolchain for you.


To install Gox, please use go get. We tag versions so feel free to checkout that tag and compile.

$ go get github.com/mitchellh/gox
$ gox -h


If you know how to use go build, then you know how to use Gox. For example, to build the current package, specify no parameters and just call gox. Gox will parallelize based on the number of CPUs you have by default and build for every platform by default:

$ gox
Number of parallel builds: 4

-->      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

Or, if you want to build a package and sub-packages:

$ gox ./...

Or, if you want to build multiple distinct packages:

$ gox github.com/mitchellh/gox github.com/hashicorp/serf

Or if you want to just build for linux:

$ gox -os="linux"

Or maybe you just want to build for 64-bit linux:

$ gox -osarch="linux/amd64"

And more! Just run gox -h for help and additional information.

Versus Other Cross-Compile Tools

A big thanks to these other options for existing. They each paved the way in many aspects to make Go cross-compilation approachable.

  • Dave Cheney's golang-crosscompile - Gox compiles for multiple platforms and can therefore easily run on any platform Go supports, whereas Dave's scripts require a shell. Gox will also parallelize builds. Dave's scripts build sequentially. Gox has much easier to use OS/Arch filtering built in.

  • goxc - A very richly featured tool that can even do things such as build system packages, upload binaries, generate download webpages, etc. Gox is a super slim alternative that only cross-compiles binaries. Gox builds packages in parallel, whereas goxc doesn't. Gox doesn't enforce a specific output structure for built binaries.

  • Impossible to build toolchain (OS X, Go 1.1.2 from Homebrew)

    Impossible to build toolchain (OS X, Go 1.1.2 from Homebrew)

    I can't build the toolchain using gox -build-toolchain. Here's a Gist

    I'm running OS X 10.9 and Go 1.1.2 from Homebrew. I'm going to try using the official Go installer, it's probably a Homebrew-specific problem.

    Edit: The official 1.1.2 installer fails without an error message, I'm going to try installing go from source.

    opened by gregkare 17
  •  Can't build due to : can't load package: package command-line-arguments

    Can't build due to : can't load package: package command-line-arguments

    Can't use gox to build any project.. It show the error info below: () Stderr: can't load package: package command-line-arguments: cannot find package "command-line-arguments" in any of: /usr/local/go/src/command-line-arguments (from $GOROOT) /opt/wh/src/command-line-arguments (from $GOPATH)

    And here is my go env and I am using Mac:

    GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/opt/wh/go" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/c4/wc4z8_dx1cb6bq2sfrdc76540000gn/T/go-build143723401=/tmp/go-build -gno-record-gcc-switches -fno-common" CXX="clang++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config"

    opened by 309382570 11
  • Update Platforms to Go 1.10

    Update Platforms to Go 1.10

    This adds all platforms up to Go 1.9 Tests are updated to support Go versions > 1.5 The OsList and ArchList variables are removed as they appear unused

    Signed-off-by: Dave Tucker [email protected]

    opened by dave-tucker 11
  • add support for s390x with go1.7

    add support for s390x with go1.7

    Go 1.7 adds support for s390x. This PR changes gox to be able to compile on it.

    Tests pass:

    $ go test
    ok  	github.com/andrewhsu/gox	0.194s

    Example compile using gox specifying s390x

    $ gox -osarch=linux/s390x github.com/docker/cli/cmd/docker
    Number of parallel builds: 3
    -->     linux/s390x: github.com/docker/cli/cmd/docker
    $ file docker_linux_s390x 
    docker_linux_s390x: ELF 64-bit MSB executable, IBM S/390, version 1 (SYSV), statically linked, not stripped
    opened by andrewhsu 9
  • Enabling CGO for native builds

    Enabling CGO for native builds

    I could easily be missing something here so please feel free to correct me, but it seems as though CGO should be enabled when building a binary for the platform you're running on even if CGO_ENABLED hasn't been set. This behaviour would then line up with Go's own build tool (source).

    opened by leonsodhi 9
  • Continuation of gox project

    Continuation of gox project

    The gox project is of great use for us and I would love to see this project further developed with support for additional platforms which were added to Golang. There haven't been much changes in the last year but based on the forks and open PR's there seems to be interest from the community. Looking at the forks of the projects (https://github.com/mitchellh/gox/network) a few forks have integrated open PR's for their own needs I assume.

    Instead of having the changes in different places I would love to see this project moving forward in one place. My preferred option would be in this repository here or a "blessed" fork form @mitchellh . @mitchellh could you share your thoughts on the future of this project? Thanks a lot for all the work you put into this so far.

    Mentioning @mattfarina @dave-tucker @roscopecoltran @AlexHaber here as I see you guys forked and changed the project very recently and curious to here your thoughts.

    opened by ruflin 8
  • cgo darwin -> linux/amd64 fails

    cgo darwin -> linux/amd64 fails

    Using go1.3, cross compiling to Linux/amd64, I get a failure compiling sqlite3. Easy example case bellow:

    gox -verbose -osarch linux/amd64 github.com/mattn/go-sqlite3/_example/simple
    Number of parallel builds: 4
    -->     linux/amd64: github.com/mattn/go-sqlite3/_example/simple
    1 errors occurred:
    --> linux/amd64 error: exit status 2
    Stderr: # github.com/mattn/go-sqlite3
    ../github.com/mattn/go-sqlite3/sqlite3.c:92 unknown #: if
    ../github.com/mattn/go-sqlite3/sqlite3.c:94 6c: No such file or directory: mingw.h

    Is this an expected failure?

    From what I can find, this would be expected to work with Go 1.3: https://code.google.com/p/go/issues/detail?id=4714

    opened by pquerna 8
  • Support for Go 1.3?

    Support for Go 1.3?

    The gox -build-toolchain command gives the following output (running under OSX 10.9):

    The toolchain build can't be parallelized because compiling a single Go source directory can only be done for one platform at a time. Therefore, the toolchain for each platform will be built one at a time.

    --> Toolchain: darwin/386 --> Toolchain: darwin/amd64 --> Toolchain: linux/386 --> Toolchain: linux/amd64 --> Toolchain: linux/arm --> Toolchain: freebsd/386 --> Toolchain: freebsd/amd64 --> Toolchain: openbsd/386 --> Toolchain: openbsd/amd64 --> Toolchain: windows/386 --> Toolchain: windows/amd64 --> Toolchain: freebsd/arm --> Toolchain: netbsd/386 --> Toolchain: netbsd/amd64 --> Toolchain: netbsd/arm --> Toolchain: plan9/386

    16 errors occurred: darwin/386: Error building 'darwin/386'.

    Stdout: # Building C bootstrap tool. cmd/dist

    Stderr: ld: can't open output file for writing 'cmd/dist/dist.ld_32P5tP', errno=13 for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

    darwin/amd64: Error building 'darwin/amd64'.

    Stdout: # Building C bootstrap tool. cmd/dist

    Stderr: ld: can't open output file for writing 'cmd/dist/dist.ld_RJ1jHq', errno=13 for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

    And so on...

    opened by oleksandr 8
  • New tag?

    New tag?

    I was looking into making a Homebrew formula for this, but noticed that the most recent tag is quite a bit older than HEAD, and Homebrew only distributes tagged releases. Any chance of getting a new tag?

    opened by ilovezfs 6
  • What is go_test.go used for?

    What is go_test.go used for?

    As evidenced by e.g. commit https://github.com/mitchellh/gox/commit/733261c, go_test.go needs to be updated for each Go release.

    I don’t see the value which go_test.go provides. What is it useful for?

    Can’t we just delete it and avoid having to update it whenever there’s a new Go release?

    opened by stapelberg 6
  • Build an executable from non package files

    Build an executable from non package files

    Wanted to check with you how I would build a 'main' package into multiple distributions using gox. For example, if I had a helloworld.go, and I wanted it built as an executable for all platforms using gox, how would I do it?

    E.g. something like: gox helloworld.go Right now it throws an error. Stderr: can't load package: package : cannot find package "_" in any of $GOPATH, $GOROOT.

    opened by sathishvj 6
  • gox silently ignores unregistered targets

    gox silently ignores unregistered targets

    Hi, I am configuring gox to output:

    • Linux RISV-V targets (linux/riscv)
    • Windows ARM64 targets (windows/arm64)
    • FreeBSD ARM64 targets (freebsd/arm64)
    • Linux, Windows, and FreeBSD AMD64 targets

    The official Go release documentation says these should be perfectly valid targets. However, gox silently ignores the first three targets. No error emits to the console. No non-zero status code reports. Neither does gox actually produce the desired binaries.

    I'm not even using cgo. This is Hello World I'm trying to port.

    opened by mcandre 1
  • Many tuples missing

    Many tuples missing

    Windows ARM and ARM64 are missing. Honestly, the gox database appears to have fallen behind the regular Go releases, in terms of basic target tuple support.


    Working around this by using standard Go queries to get the most recent platform list.


    opened by mcandre 0
Mitchell Hashimoto
Mitchell Hashimoto
Monitoring changes in the source file and automatically compile and run (restart).

dogo Monitoring changes in the source file and automatically compile and run (restart). 中文 Install go get github.com/liudng/dogo Create config Here's

null 254 Dec 28, 2022
Lightweight and dead-simple CI detection.

is-ci Lightweight and dead-simple CI detection for golang. This mod is based on the @npmcli/ci-detect package. Install go get -u github.com/wesleimp/i

Weslei Juan Novaes Pereira 4 Dec 17, 2021
Fast cross-platform HTTP benchmarking tool written in Go

bombardier bombardier is a HTTP(S) benchmarking tool. It is written in Go programming language and uses excellent fasthttp instead of Go's default htt

Максим Федосеев 3.9k Jan 2, 2023
:rocket: Modern cross-platform HTTP load-testing tool written in Go

English | 中文 Cassowary is a modern HTTP/S, intuitive & cross-platform load testing tool built in Go for developers, testers and sysadmins. Cassowary d

Roger Welin 643 Dec 29, 2022
a build tool for Go, with a focus on cross-compiling, packaging and deployment

goxc NOTE: goxc has long been in maintenance mode. Ever since Go1.5 supported simple cross-compilation, this tool lost much of its value. There are st

Am Laher 1.7k Dec 9, 2022
Cross-platform beanstalkd queue server admin console.

Overview aurora is a web-based Beanstalkd queue server console written in Go and works on macOS, Linux, and Windows machines. The main idea behind usi

null 571 Dec 30, 2022
Build Go Toolchains /w native libs for cross-compilation

gonative Cross compiled Go binaries are not suitable for production applications because code in the standard library relies on Cgo for DNS resolution

Alan Shreve 336 Dec 20, 2022
A cross platform CLI for Flyte. Written in Golang. Offers an intuitive interface to Flyte https://flytectl.readthedocs.io/en/latest/

FlyteCTL Flyte's official command-line interface Documentation · Contribution Guide FlyteCTL was designed as a portable and lightweight command-line i

Flyte 31 Nov 7, 2022
A cross-language distributed transaction manager

English Docs 跨语言分布式事务管理器 DTM是一款golang开发的分布式事务管理器,解决了跨数据库、跨服务、跨语言栈更新数据的一致性问题。 他优雅

DTM Development and Communities 8.1k Dec 31, 2022
Based on the electron Cross-platform Mini browser

Based on the electron Cross-platform Mini browser

池边树下 1 May 1, 2022
Defalyzer: A cross-platform software that focuses on defacement analyzing and mirror tracking

Project Defalyzer is a cross-platform software that focuses on defacement analyz

numaN 13 Jul 26, 2022
Nycmesh-tool - nycmesh-tool CLI

nycmesh-tool nycmesh-tool CLI Features At the moment, the tool is pretty sparse. It provides the top level nycmesh-tool command, with subcommands for:

Gabe Conradi 1 Jun 17, 2022
Terraform-equinix-migration-tool - Tool to migrate code from Equinix Metal terraform provider to Equinix terraform provider

Equinix Terraform Provider Migration Tool This tool targets a terraform working

Equinix 1 Feb 15, 2022
Blast is a simple tool for API load testing and batch jobs

Blast Blast makes API requests at a fixed rate. The number of concurrent workers is configurable. The rate may be changed interactively during executi

Dave Brophy 209 Nov 10, 2022
Super simple deployment tool

Dropship Dropship is a simple tool for installing and updating artifacts from a CDN. Features Automatically performs md5sum checks of artifact that is

Christopher McKenzie 62 Oct 4, 2022
Go version manager. Super simple tool to install and manage Go versions. Install go without root. Gobrew doesn't require shell rehash.

gobrew Go version manager Install or update With curl $ curl -sLk https://git.io/gobrew | sh - or with go $ go get -u github.com/kevincobain2000/gobre

Pulkit Kathuria 180 Jan 5, 2023
Simple CLI tool and Kubernetes deployment.

Simple Application A basic example of how to build a naml project. app.go Every project should define an app.go file. The file should implement the De

NAML Examples 11 Dec 21, 2022
An advanced, yet simple, tunneling/pivoting tool that uses a TUN interface.

Ligolo-ng : Tunneling like a VPN An advanced, yet simple, tunneling tool that uses a TUN interface. by TNP IT Security Table of Contents Introduction

TNP IT Security 415 Dec 31, 2022
A simple tool who pulls data from Online.net API and parse them to a Prometheus format

Dedibox backup monitoring A simple tool who reads API from Online.net and parse them into a Prometheus-compatible format. Conceived to be lightweight,

Florian Forestier / Artheriom 4 Aug 16, 2022