alexbrainman / odbc

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

Linux: Can't build when use this package #111

Closed Demitroi closed 6 years ago

Demitroi commented 6 years ago

Hi Alex,

This package is awesome and works fine on Windows. But when i try build in linux throws the next error:

env GOOS=linux GOARCH=amd64 go build -o tw main.go

github.com/alexbrainman/odbc/api
..\..\..\github.com\alexbrainman\odbc\api\api.go:17: undefined: SQLSMALLINT
..\..\..\github.com\alexbrainman\odbc\api\api.go:18: undefined: SQLUSMALLINT
..\..\..\github.com\alexbrainman\odbc\api\api.go:19: undefined: SQLUSMALLINT

I'm trying to build in a Windows 7 x64 machine.

go version go1.8.3 windows/386

Maybe some Windows things are not available on Linux.

alexbrainman commented 6 years ago

Maybe some Windows things are not available on Linux.

That is correct. This package does not talk to the database directly, it uses whatever ODBC driver OS has installed.

So, for example, Windows have generally some ODBC drivers installed, and your program will work on Windows as is, but even there you sometimes need to install ODBC drivers.

On non-Windows on the other hand, ODBC drivers are only accessible via C interface. So this package uses cgo to access that. I doubt you would be able to cross-compile cgo Linux code on Windows - for that you would need Windows version of gcc that has all Linux versions of required code. I am not an expert, but I think cross-compiling in C is not easy. You might have much better chance to build your program on Linux. But even then you would need to install and configure some extra software. See https://github.com/alexbrainman/odbc/wiki/GettingStartedOnLinux for some suggestions.

Alex

Demitroi commented 6 years ago

Thanks for your attention Alex

The better alternative is build in a linux machine.

Demitroi