mmottl / gsl-ocaml

OCaml bindings to the GSL (GNU Scientific Library).
Other
36 stars 10 forks source link

installation with homebrew openblas on os x #21

Closed nilsbecker closed 7 years ago

nilsbecker commented 7 years ago

hi, i was delighted to see the new build setup with the option to specify a custom blas. i tried to use that on os x to set up gsl with openblas (accelerate causes other problems for me). my openblas is installed via homebrew in a location outside the usual search paths to not interfere with accelerate. i get this info from homebrew:

This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides BLAS and LAPACK in the Accelerate framework.

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openblas/lib
    CPPFLAGS: -I/usr/local/opt/openblas/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/openblas/lib/pkgconfig

i now tried this invocation:

 GSL_CBLAS_LIB=-lopenblas  PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig LDFLAGS=-L/usr/local/opt/openblas/lib CPPFLAGS=-I/usr/local/opt/openblas/include opam install gsl

which fails:

ld: library not found for -lopenblas

any help would be appreciated!

mmottl commented 7 years ago

Back from vacation. Could you please try out whether GSL_CBLAS_LIB="-L/usr/local/... -lopenblas" works? If not, it would be great if you could submit a patch for src/config/discover.ml that allows you to do that. This may be as simple as splitting the contents of this variable (in alt_blas) on whitespace into a list of strings that are then concatenated with without_cblas instead of consing alt_blas.

nilsbecker commented 7 years ago

ok, so your suggestion works: i successfully installed gsl with GSL_CBLAS_LIB="-L/usr/local/opt/openblas/lib/ -lopenblas" opam install gsl. the other path settings do not seem to be necessary. will look into making the PR now.

nilsbecker commented 7 years ago

ah wait. i misunderstood: you were suggesting to submit a patch only if the double option in GSL_CBLAS_LIB does not work. but it does. so basically, the only thing is to alert users to the necessity of the "-L .." yes? i'll look if i can add a sentence to the readme.

nilsbecker commented 7 years ago

btw, when doing the unnecessary changes to discover.ml i was exposed to jbuilder for the first time. it's fast! are you planning to do the switch also for lacaml? if yes please also introduce the blas user-configuration in the same way as here!

mmottl commented 7 years ago

Yes, if it works for you, a mere documentation improvement as proposed suffices. I have already ported Lacaml to jbuilder and topkg, but haven't made a release yet. This should happen within a few days, including the proposed documentation improvement. jbuilder is indeed quite a lot faster than alternatives.

nilsbecker commented 7 years ago

cool! then i can finally get rid of my pinned version with edited _oasis... thanks.