crawshaw / sqlite

Go SQLite3 driver
ISC License
561 stars 67 forks source link

Build fails on 386 #102

Closed anacrolix closed 3 years ago

anacrolix commented 3 years ago

Note I am doing this from linux/amd64, and the fork doesn't change anything that would affect this build:

# GOARCH=386 go build ./...
# crawshaw.io/sqlite/sqlitex
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/buffer.go:38:8: undefined: sqlite.Conn
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/buffer.go:51:9: undefined: sqlite.Blob
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/buffer.go:56:22: undefined: sqlite.Conn
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/buffer.go:61:26: undefined: sqlite.Conn
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/exec.go:73:17: undefined: sqlite.Conn
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/exec.go:73:64: undefined: sqlite.Stmt
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/exec.go:91:26: undefined: sqlite.Conn
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/exec.go:91:73: undefined: sqlite.Stmt
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/exec.go:110:17: undefined: sqlite.Stmt
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/exec.go:176:23: undefined: sqlite.Conn
/root/go/pkg/mod/github.com/zombiezen/sqlite@v0.3.3-0.20200630223153-bdd2fdca1601/sqlitex/exec.go:176:23: too many errors

I'm not sure if this is due to a cgo shortcoming for cross-compiling or something else.

cugu commented 3 years ago

I had the same error.

You can do something like:

sudo apt-get install mingw-w64
CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build .

Maybe just the CGO_ENABLED=1 is enough.

anacrolix commented 3 years ago

Thanks @cugu. CGO_ENABLED was necessary to get the package to try to build the stuff it was missing. On Ubuntu, apt install gcc-multilib installed the necessary stuff to build for 32-bit.

# apt install gcc-multilib
# CGO_ENABLED=1 GOARCH=386 go build ./...