gonum / blas

A BLAS implementation for Go [DEPRECATED]
172 stars 16 forks source link

go test for cblas fails on osx #62

Closed jonlawlor closed 9 years ago

jonlawlor commented 9 years ago

I tried running go test in the gonum/blas/cblas directory and it fails on OSX Yosemite (10.10.1) with

jonlawlor: ~/go/src/github.com/gonum/blas/cblas $ go test
# github.com/gonum/blas/cblas
Undefined symbols for architecture x86_64:
  "_cblas_caxpy", referenced from:
      __cgo_00cfc60828b5_Cfunc_cblas_caxpy in blas.cgo2.o
     (maybe you meant: __cgo_00cfc60828b5_Cfunc_cblas_caxpy)
  "_cblas_ccopy", referenced from:
      __cgo_00cfc60828b5_Cfunc_cblas_ccopy in blas.cgo2.o
     (maybe you meant: __cgo_00cfc60828b5_Cfunc_cblas_ccopy)
  "_cblas_cdotc_sub", referenced from:
      __cgo_00cfc60828b5_Cfunc_cblas_cdotc_sub in blas.cgo2.o
     (maybe you meant: __cgo_00cfc60828b5_Cfunc_cblas_cdotc_sub)
  "_cblas_cdotu_sub", referenced from:
      __cgo_00cfc60828b5_Cfunc_cblas_cdotu_sub in blas.cgo2.o
     (maybe you meant: __cgo_00cfc60828b5_Cfunc_cblas_cdotu_sub)
... and a lot more

References to cblas in matrix still work. I tried installing from scratch on a different mac, where I've never fiddled with various blas libraries:

go get github.com/gonum/blas
go get github.com/gonum/floats
cd $GOPATH/src/github.com/gonum/blas/cblas
CGO_LDFLAGS="-framework Accelerate" go install

but it produced the same result.

btracey commented 9 years ago

Uhh...

brendan:~/Documents/mygo/src/github.com/gonum/blas/cblas$ echo $CGO_LDFLAGS -framework Accelerate brendan:~/Documents/mygo/src/github.com/gonum/blas/cblas$ go test PASS ok github.com/gonum/blas/cblas 0.052s

Operating system: OSX Yosemite 10.10.1

btracey commented 9 years ago

Also: brendan:~/Documents/mygo/src/github.com/gonum/blas/cblas$ CGO_LDFLAGS="-framework Accelerate" go test PASS ok github.com/gonum/blas/cblas 0.042s

btracey commented 9 years ago

I don't have another mac, but using a new GOPATH

brendan:~/Documents/thirdgo/src$ export CGO_LDFLAGS="-framework Accelerate" brendan:~/Documents/thirdgo/src$ go get -t github.com/gonum/blas/cblas brendan:~/Documents/thirdgo/src$ go test github.com/gonum/blas/cblas/ ok github.com/gonum/blas/cblas 0.036s

jonlawlor commented 9 years ago

Arrrgh. It works fine with the flags exported. It doesn't work if you CGO_LDFLAGS="-framework Accelerate" go install and then go test. I might just be dense, but I'd like to add a little to the readme to explain that you're better off with the flag exported.

kortschak commented 9 years ago

@jonlawlor, have a look at how go test actually works, that will explain this behaviour. go test does a complete build that is independent of the installed code, so you need to either prefix the env var declaration or export it.

jonlawlor commented 9 years ago

Yes, I won't forget that now.