in Mac build error
hktalent opened this issue · 3 comments
hktalent commented
Mac OS
$ GOOS=windows GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o main_windows_amd64.exe main.go
server/webserver.go:335:25: undefined: sqlite3.Error
server/webserver.go:339:24: undefined: sqlite3.ErrConstraint
but, build for Mac,is ok
go build main.go
rittneje commented
When cross-compiling, Go requires that you explicitly enable cgo via CGO_ENABLED=1
. In addition, you must set CC
to a valid C cross-compiler.
hktalent commented
@rittneje how set cc ,thanks
https://gist.github.com/steeve/6905542
I have referenced here and have no success
rittneje commented
First you will need to install a C compiler that runs on macos but targets Windows. I've never done this, but mingw-w64 might work. https://formulae.brew.sh/formula/mingw-w64
Then set the CC
environment variable to the path to that C compiler when running go build
.