alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
348 stars 139 forks source link

Cross-compiling: can't build this package on linux for darwin #148

Closed i-pva closed 3 years ago

i-pva commented 3 years ago

Hi I have tried to build this package on linux for darwin but I got error: go1.15

user@pc:$ env CGO_ENABLE=1 GOOS=darwin GOARCH=amd64 go build -v

.../github.com/alexbrainman/odbc/api/api.go:17:9: undefined: SQLSMALLINT .../github.com/alexbrainman/odbc/api/api.go:18:9: undefined: SQLUSMALLINT .../github.com/alexbrainman/odbc/api/api.go:19:9: undefined: SQLUSMALLINT .../github.com/alexbrainman/odbc/api/api.go:23:10: undefined: SQLUSMALLINT .../github.com/alexbrainman/odbc/api/api.go:24:10: undefined: SQLUSMALLINT .../github.com/alexbrainman/odbc/api/api.go:25:10: undefined: SQLUSMALLINT .../github.com/alexbrainman/odbc/api/api.go:29:12: undefined: SQLUSMALLINT .../github.com/alexbrainman/odbc/api/api.go:30:12: undefined: SQLUSMALLINT .../github.com/alexbrainman/odbc/api/api.go:31:12: undefined: SQLUSMALLINT .../github.com/alexbrainman/odbc/api/api.go:32:12: undefined: SQLUINTEGER .../github.com/alexbrainman/odbc/api/api.go:32:12: too many errors

Have you any idea about it? Thank you for advance.

alexbrainman commented 3 years ago

Hello,

Normal Go programs can easily be cross-complied out of the box.

But github.com/alexbrainman/odbc package uses Cgo on Darwin. So you would need all correspondent C tools installed.

I have never done it myself - I use this package on Windows. And Windows version of github.com/alexbrainman/odbc does not use Cgo. So I can build it on Linux.

I just googled, and I find

https://stackoverflow.com/questions/34084597/cross-compilation-of-cgo-for-darwin-fails

But, please, do not assume that I know this area. Just google yourself.

Alex

i-pva commented 3 years ago

I've tested it by doing

env OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 MACOSX_DEPLOYMENT_TARGET=10.6 CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -v mywork/myprogra

it helped me but i got error before:

exec: "o64-clang": executable file not found in $PATH it was necessary to install it

Thank you for answering I'll close that issue