Skip to content

Commit

Permalink
Cross Compiling for Mac OS via musl-cross
Browse files Browse the repository at this point in the history
# Enhancement

Update `README.md` with new instructions for Mac OS cross compiling.

# Why?

The current suggested solution `xgo` is no longer maintained (GitHub archived repository).

# Credits

Credits go to Pieter Claerhout (@pieterclaerhout) and his blog post: https://www.yellowduck.be/posts/cross-compile-a-go-package-which-uses-sqlite3
  • Loading branch information
jodosha authored and mattn committed Sep 18, 2022
1 parent be28dec commit 90900be
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,13 @@ This library can be cross-compiled.
In some cases you are required to the `CC` environment variable with the cross compiler.

## Cross Compiling from MAC OSX
The simplest way to cross compile from OSX is to use [xgo](https://github.com/karalabe/xgo).
The simplest way to cross compile from OSX is to use [musl-cross](https://github.com/FiloSottile/homebrew-musl-cross).

Steps:
- Install [xgo](https://github.com/karalabe/xgo) (`go get github.com/karalabe/xgo`).
- Ensure that your project is within your `GOPATH`.
- Run `xgo local/path/to/project`.
- Install [musl-cross](https://github.com/FiloSottile/homebrew-musl-cross) (`brew install FiloSottile/musl-cross/musl-cross`).
- Run `CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++ GOARCH=amd64 GOOS=linux CGO_ENABLED=1 go build -ldflags "-linkmode external -extldflags -static"`.

Please refer to the project's [README](https://github.com/karalabe/xgo/blob/master/README.md) for further information.
Please refer to the project's [README](https://github.com/FiloSottile/homebrew-musl-cross#readme) for further information.

# Google Cloud Platform

Expand Down

0 comments on commit 90900be

Please sign in to comment.