From 3c9cdd26e3498ef08e2a07c14d4107cebdbe640d Mon Sep 17 00:00:00 2001 From: Vishnu Mohandas Date: Fri, 17 Apr 2020 20:13:06 +0530 Subject: [PATCH 1/2] Document requirements for cross compiling from OSX Inspiration: https://github.com/mattn/go-sqlite3/issues/384#issuecomment-433584967 --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 7cdad13f..a8633134 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,24 @@ 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 +Install the `musl-cross` and `mingw-w64` formulae. +```bash +brew install FiloSottile/musl-cross/musl-cross +brew install mingw-w64 +``` +During cross compilation, in addition to `CGO_ENABLED=1`, define the `CC` and `CXX` flags depending on the target platform: +- Windows + ``` + CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ + ``` +- Linux + ``` + CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++ + ``` + Additional information: +- [#384](https://github.com/mattn/go-sqlite3/issues/384) - [#491](https://github.com/mattn/go-sqlite3/issues/491) - [#560](https://github.com/mattn/go-sqlite3/issues/560) From 931bb2728d78d834a94a604099f301f5668778aa Mon Sep 17 00:00:00 2001 From: Vishnu Mohandas Date: Fri, 8 May 2020 04:44:45 +0530 Subject: [PATCH 2/2] Document cross compilation steps using xgo for MACOSX --- README.md | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a8633134..e977fd6a 100644 --- a/README.md +++ b/README.md @@ -213,25 +213,14 @@ 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 -Install the `musl-cross` and `mingw-w64` formulae. -```bash -brew install FiloSottile/musl-cross/musl-cross -brew install mingw-w64 -``` -During cross compilation, in addition to `CGO_ENABLED=1`, define the `CC` and `CXX` flags depending on the target platform: -- Windows - ``` - CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ - ``` -- Linux - ``` - CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++ - ``` +The simplest way to cross compile from OSX is to use [xgo](https://github.com/karalabe/xgo). -Additional information: -- [#384](https://github.com/mattn/go-sqlite3/issues/384) -- [#491](https://github.com/mattn/go-sqlite3/issues/491) -- [#560](https://github.com/mattn/go-sqlite3/issues/560) +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`. + +Please refer to the project's [README](https://github.com/karalabe/xgo/blob/master/README.md) for further information. # Google Cloud Platform