Code Monkey home page Code Monkey logo

Comments (6)

hut8 avatar hut8 commented on September 26, 2024 1

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 go get succeeded without errors but then actually trying to use the package only partly succeeded (with warnings).

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 😓

from odbc.

alexbrainman avatar alexbrainman commented on September 26, 2024

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

from odbc.

bdgca-wjp avatar bdgca-wjp commented on September 26, 2024

You need install unixodbc package. For example, on Ubuntu you would need to do:

sudo apt install unixodbc-dev

from odbc.

hut8 avatar hut8 commented on September 26, 2024

I'm getting the same error and am rather confused by it...

go get github.com/alexbrainman/odbc/api # works fine
go get github.com/alexbrainman/odbc # works fine

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 go build from that directory, it fails with:

# github.com/alexbrainman/odbc/api
../../go/pkg/mod/github.com/alexbrainman/[email protected]/api/api_unix.go:15:11: fatal error: 'sql.h' file not found
 #include <sql.h>
          ^~~~~~~
1 error generated.

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)

from odbc.

hut8 avatar hut8 commented on September 26, 2024

Running this command gets me a working executable, but prints out warnings:

$ CGO_CFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.12/include" CGO_LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/2.3.12/lib" go build
# inventory
ld: warning: ignoring duplicate libraries: '-lodbc'
ld: warning: search path '/usr/local/opt/unixodbc/lib' not found

from odbc.

alexbrainman avatar alexbrainman commented on September 26, 2024

@hut8

I don't use Mac OS myself.

But try following https://github.com/alexbrainman/odbc/wiki/GettingStartedOnOSX , perhaps it will help.

Alex

from odbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.