go-sqlite3: Cross compiling failed.
go Version
go version go1.7.4 darwin/amd64
go env
GOARCH="amd64"
GOBIN="/Users/CosPotato/GoProjects/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/CosPotato/GoProjects"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2g/4x1xzstj4vdbj939flg1q7v00000gn/T/go-build152787034=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
what i do
GOOS=linux GOARCH=amd64 ENABLE_CGO=1 go build -o task-server task-server
what i get
github.com/mattn/go-sqlite3
GoProjects/src/github.com/mattn/go-sqlite3/tracecallback_noimpl.go:39: undefined: Error
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 25 (17 by maintainers)
@GJRTimmer thank you for taking the time to make the instructions! I also found the ‘FiloSottile/musl-cross/musl-cross’ and tried it out without success. I get the following error when trying to cross-compile from macOS to linux:
After some research it looks like the problem is the version of the gcc is outdated, I can be way off and this might be obvious to someone else. So if anybody stumbles on this, then please try to see if the x86_64-linux-musl-gcc works for you. I however ended up giving up on the cross-compiler and just compiled it in a docker golang container. I modified the golang container so that it includes gcc and musl-dev:
then I created the docker image e.g.
where $(PROJECT) is the path to your project.
Thank you again for the help!
@arnigudj Check out the file
.travis-ci.yml
when are building for Mac, you can use thebrew
commands shown in the travis config.Then look at the logfile of the one of the builds: https://travis-ci.org/mattn/go-sqlite3/builds/391540953 and try to see what it is they are installing.
I’ve done some homework for you. The following will probably work.
Install cross compilers on your Mac.
For example to cross compile FOR Windows 64Bit FROM you Mac.
Use the following
go
commandDo not forget the
-a
this will recompile all the go internal packages for the required target.From this link: https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/
Let us know if you are succesfull with the above, after that you can find a compiler for your desired target and install it with
brew
and compile what you want.use gcc instead of clang.
Ok, the latest commit is now working again. Thank you.
Could you please try last commit again?
I’m having these exact same issues. This should compile using
go build
. Telling people to use other compilation tools isn’t the correct way to solve this.This package has recently become very unstable. Not sure why, but it seems that the last few weeks there are have been several commits that have broken this project.
please update go-sqlite3