Skip to content
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

Painful installation on MacOS #625

Closed
jonathan-laurent opened this issue Nov 4, 2022 · 5 comments
Closed

Painful installation on MacOS #625

jonathan-laurent opened this issue Nov 4, 2022 · 5 comments

Comments

@jonathan-laurent
Copy link

jonathan-laurent commented Nov 4, 2022

I tried to install owl on MacOS Monterey (x86-64) after running brew install openblas.
Ideally, opam install owl should just work. However, I had to do:

export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/openblas/include"

ln -s /usr/local/Cellar/gcc/12.2.0/lib/gcc/12/libquadmath.0.dylib /usr/local/lib/libquadmath.0.dylib
ln -s /usr/local/Cellar/gcc/12.2.0/lib/gcc/12/libgcc_s.1.1.dylib /usr/local/lib/libgcc_s.1.1.dylib

opam install owl

The first block seems to be necessary since homebrew's openblas installation is kegonly (since MacOS ships with its own version of openblas). Removing it results in the following error:

#=== ERROR while compiling conf-openblas.0.2.1 ==============================#
# context     2.0.6 | macos/x86_64 | ocaml-base-compiler.4.14.0 | https://opam.ocaml.org#67c37f4f
# path        ~/.opam/research/.opam-switch/build/conf-openblas.0.2.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build sh -exc cc $CFLAGS $(pkg-config --cflags openblas) test.c $(pkg-config --libs openblas)
# exit-code   1
# env-file    ~/.opam/log/conf-openblas-67509-a00279.env
# output-file ~/.opam/log/conf-openblas-67509-a00279.out
### output ###
# [...]
# to the PKG_CONFIG_PATH environment variable
# No package 'openblas' found
# ++ pkg-config --libs openblas
# Package openblas was not found in the pkg-config search path.
# Perhaps you should add the directory containing `openblas.pc'
# to the PKG_CONFIG_PATH environment variable
# No package 'openblas' found
# + cc test.c
# test.c:2:10: fatal error: 'cblas.h' file not found
# #include <cblas.h>
#          ^~~~~~~~~
# 1 error generated.

Removing the second block results in the following error:

#=== ERROR while compiling owl.1.0.2-1 ======================================#
# context     2.0.6 | macos/x86_64 | ocaml-base-compiler.4.14.0 | https://opam.ocaml.org#67c37f4f
# path        ~/.opam/research/.opam-switch/build/owl.1.0.2-1
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p owl -j 3
# exit-code   1
# env-file    ~/.opam/log/owl-69979-335865.env
# output-file ~/.opam/log/owl-69979-335865.out
### output ###
# [...]
# 215 |  (libraries ctypes ctypes.stubs eigen owl-base npy))
# (cd _build/default && /Users/jlauren1/.opam/research/bin/ocamlmklib.opt -g -o src/owl/owl_stubs src/owl/zetac.o src/owl/zeta.o src/owl/ynf.o src/owl/yn.o src/owl/unity.o src/owl/tukey.o src/owl/tandg.o src/owl/struvef.o src/owl/struve.o src/owl/stdtr.o src/owl/sqrtf.o src/owl/spence.o src/owl/sindg.o src/owl/sincos.o src/owl/sici.o src/owl/shichi.o src/owl/sf_error.o src/owl/scipy_iv.o src/ow[...]
# ld: file not found: @rpath/libquadmath.0.dylib for architecture x86_64
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# (cd _build/default && /Users/jlauren1/.opam/research/bin/ocamlc.opt -w -40 -g -bin-annot -I src/owl/.owl.objs/byte -I /Users/jlauren1/.opam/research/lib/bigarray-compat -I /Users/jlauren1/.opam/research/lib/camlzip -I /Users/jlauren1/.opam/research/lib/ctypes -I /Users/jlauren1/.opam/research/lib/eigen -I /Users/jlauren1/.opam/research/lib/eigen/cpp -I /Users/jlauren1/.opam/research/lib/integ[...]

The problem seems to be that some recent clang versions do not ship with libquadmath.0.dylib and libgcc_s.1.1.dylib so I ended up adding them manually (as suggested here).

It is my understanding that the whole purpose of the conf-openblas package on which owl depends is to avoid these difficulties. Did anyone else encounter the same problems?

@mseri
Copy link
Member

mseri commented Nov 4, 2022

This should be solved if #609 is merged and released.

A slightly more straightforward option is to use macports, with that it just works on intel, no env variable needed.

@anentropic
Copy link

The solution from OP did not work for me

I'm on M1 mac so the homebrew paths are different

so I changed these to the paths that exist:

ln -s /opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/12/libquadmath.0.dylib /usr/local/lib/libquadmath.0.dylib
ln -s /opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/12/libgcc_s.1.1.dylib /usr/local/lib/libgcc_s.1.1.dylib

but I still get the same error

# No package 'openblas' found
# ++ pkg-config --libs openblas
# Package openblas was not found in the pkg-config search path.
# Perhaps you should add the directory containing `openblas.pc'
# to the PKG_CONFIG_PATH environment variable
# No package 'openblas' found
# + cc test.c
# test.c:2:10: fatal error: 'cblas.h' file not found
# #include <cblas.h>
#          ^~~~~~~~~
# 1 error generated.

@anentropic
Copy link

anentropic commented Nov 11, 2022

if I delete the symlinks from above and try the instruction from the PR mentioned:

opam pin -n git+https://github.com/mseri/owl.git#arm64 --with-version=1.1.0
PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig" opam install owl.1.1.0

then this works.

@nilsbecker
Copy link
Contributor

nilsbecker commented Jan 25, 2023

fwiw, on my Intel mac with homebrew the above solution does not work. maybe expected since it seems to be targeted at M1 macs. i also tried a modified version with PKG_CONFIG_PATH=/usr/local/opt/openblas/lib opam install owl.1.1.0 which failed finding libquadmath.0.dylib. on my machine that shared lib resides in /usr/local/gfortran/lib, installed by homebrew as well

@jzstark
Copy link
Collaborator

jzstark commented Sep 30, 2024

This issue should have been solved by now.

@jzstark jzstark closed this as completed Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants