go version
)?go version go1.9.2 darwin/amd64
I'm using latest version
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ming/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.2/libexec/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/mm/33b_7wg94g73p0l7w8m11dvw0000gn/T/go-build649463343=/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"
I've ran GOOS=linux GOARCH=amd64 go build -v -o appname
on macOS Sierra
Successful linux cross compilation
The cross compile have been failed without any useful error messages. Just return the error code 2. But there are no any problems with go build -v -o appname
.
How can I debug it?
I can't reproduce on macOS Sierra.
Try adding -x
to go build
and post the results.
@bradfitz Thanks for letting me know -x
option.
There is a clear error message as follow:
...
mkdir -p $WORK/github.com/sundaytoz/sql-snippet-manager/vendor/github.com/mattn/
cd /Users/ming/go/src/github.com/sundaytoz/sql-snippet-manager/vendor/github.com/mattn/go-sqlite3
/usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64/compile -o $WORK/github.com/sundaytoz/sql-snippet-manager/vendor/github.com/mattn/go-sqlite3.a -trimpath $WORK -goversion go1.9.2 -p github.com/sundaytoz/sql-snippet-manager/vendor/github.com/mattn/go-sqlite3 -complete -buildid e2e40ec7a2518c0ee6542b117325619e76d5295c -importmap golang.org/x/net/context=github.com/sundaytoz/sql-snippet-manager/vendor/golang.org/x/net/context -D _/Users/ming/go/src/github.com/sundaytoz/sql-snippet-manager/vendor/github.com/mattn/go-sqlite3 -I $WORK -I /Users/ming/go/pkg/darwin_amd64 -pack ./doc.go ./sqlite3_go18.go
# github.com/sundaytoz/sql-snippet-manager/vendor/github.com/mattn/go-sqlite3
vendor/github.com/mattn/go-sqlite3/sqlite3_go18.go:18:10: undefined: SQLiteConn
...
Sorry for that I did not check carefully. Yes I got an error, this is not a problem of build command.
Thanks :)
@mingrammer have you fix the cross compilation of go-sqlite3 ?
I encounter this problem too, but can not fix it
Most helpful comment
@bradfitz Thanks for letting me know
-x
option.There is a clear error message as follow:
Sorry for that I did not check carefully. Yes I got an error, this is not a problem of build command.
Thanks :)