-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have error api/api_unix.go:15:11: fatal error: 'sql.h' file not found
#192
Comments
This error comes from cgo. If you installed unixODBC libraries, then cgo should be able to find unixODBC sql.h file. Can you build small C program that uses unixODBC package? Alex |
You need install unixodbc package. For example, on Ubuntu you would need to do:
|
I'm getting the same error and am rather confused by it...
Then if I execute: mkdir odbctest
cd odbctest
go mod init odbctest then put this in main.go in that folder: package main
import (
"database/sql"
_ "github.com/alexbrainman/odbc"
)
func querySources() {
sourceDB, err := sql.Open("odbc", "DSN=my_dsn_goes_here")
if err != nil {
panic(err)
}
defer sourceDB.Close()
}
func main() {
querySources()
} Then run
Here's proof that I have it: $ find /opt/homebrew -iname 'sql.h'
/opt/homebrew/include/sql.h
/opt/homebrew/Cellar/mailutils/3.17/include/mailutils/sql.h
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/libc/include/any-windows-any/sql.h
/opt/homebrew/Cellar/unixodbc/2.3.12/include/sql.h
$ brew info unixodbc
==> unixodbc: stable 2.3.12 (bottled)
ODBC 3 connectivity for UNIX
https://www.unixodbc.org/
Conflicts with:
virtuoso (because both install `isql` binaries)
Installed
/opt/homebrew/Cellar/unixodbc/2.3.12 (47 files, 2.3MB) *
Poured from bottle using the formulae.brew.sh API on 2023-08-16 at 16:35:33
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/u/unixodbc.rb
License: LGPL-2.1-or-later
==> Dependencies
Required: libtool ✔
==> Analytics
install: 18,758 (30 days), 57,966 (90 days), 304,584 (365 days)
install-on-request: 2,108 (30 days), 6,370 (90 days), 34,881 (365 days)
build-error: 5 (30 days) |
Running this command gets me a working executable, but prints out warnings:
|
I don't use Mac OS myself. But try following https://github.com/alexbrainman/odbc/wiki/GettingStartedOnOSX , perhaps it will help. Alex |
I appreciate you writing that page for us Mac users 😄 Unfortunately I did actually follow those directions, and the weird part that really confuses me is that However, the actual issue is now immaterial for me because Informix, which I am burdened with using, stopped making the ODBC driver for Mac, and the latest one they have doesn't work with recent versions of OSX 😓 |
I am having a similar error
Some env variables I have added: export CGO_CFLAGS="-I/opt/homebrew/opt/unixodbc/include" my files do exist:
pkg-config also seems to return the right path.
I am on the most recent version of macos. And I think that will be an issue too. go run |
I got the error
api/api_unix.go:15:11: fatal error: 'sql.h' file not found
OS: OS X
unixODBC: 2.3.12
The text was updated successfully, but these errors were encountered: