I am trying to get the owl library running on Linux Mint 18.
After installing opam, switching to ocaml 4.06.0 and installing dune, ocamlfind etc. and necessary libraries such as libopenblas-dev and liblapacke-dev the installation of owl 0.6.0 with opam install owl
succeeds.
However as soon as I try to open a package an error is thrown that undefines symbol is referenced:
let generate_data () =
let open Mat in
let c = 500 in
let x1 = (gaussian c 2 * 2.) in
let a, b = float_of_int (Random.int 15), float_of_int (Random.int 15) in
let x1 = map_at_col (fun x -> x +. a) x1 0 in
let x1 = map_at_col (fun x -> x +. b) x1 1 in
let x2 = (gaussian c 2 * 2.) in
let a, b = float_of_int (Random.int 15), float_of_int (Random.int 15) in
let x2 = map_at_col (fun x -> x +. a) x2 0 in
let x2 = map_at_col (fun x -> x +. b) x2 1 in
let y1 = create c 1 ( 1.) in
let y2 = create c 1 ( -1.)in
let x = concat_vertical x1 x2 in
let y = concat_vertical y1 y2 in
x, y
ile “s.ml”, line 1:
Error: Error on dynamically loaded library: /home/florian/.opam/4.06.0/lib/stublibs/dllowl_stubs.so: /home/florian/.opam/4.06.0/lib/stublibs/dllowl_stubs.so: undefined symbol: LAPACKE_dlagge
Extra C object files: -lowl_stubs -llapacke -lopenblas -lm
next (b), let’s double check that it is indeed there (or not there), e.g.,
$ readelf -Ws /usr/lib/liblapacke.so | grep dlagge
226: 0000000000000000 0 FUNC GLOBAL DEFAULT UND dlagge_
1282: 00000000000ba490 521 FUNC GLOBAL DEFAULT 12 LAPACKE_dlagge_work
2135: 00000000000ba390 248 FUNC GLOBAL DEFAULT 12 LAPACKE_dlagge
So on a working system (mine for example) there is the LAPACKE_dlagge symbol (without any extra annotations) and lapacke is referenced as a system dependency.
and finally, ( c ), that ldconfig knows where lapack is,
ldconfig -p | grep lapack
in your case it should point to /usr/lib/x86_64-linux-gnu/liblapacke.so
Ok, so this is the crux of the problem For some reason your lapacke on mint is not good enough, so you probably should build lapack manually.
The good question is whether dlagge is actually needed by owl, and if not then what component actually brings it in. You can use the --trace-symbol option (you have to use -ccopt together with -Wl to push it down to the linker).
Indeed, as @ivg has already noted, dlagge has been there for a long time. The thing is that owl links against openblas and expects it to be compiled to include lapacke and cblas. Unless you use js_of_ocaml, all the linear algebra routines will shell out to openblas, so you likely need it. I pin @ryanrhymes, just to make sure I am not saying something wrong here.
In most cases openblas installed by your distribution will have everything you need, but this is currently known to be broken (and it has been for quite a while) on ubuntu. The only solution that we have been able to find is the one we use also in the ubuntu Docker file: https://github.com/owlbarn/owl/blob/master/docker/Dockerfile.ubuntu#L20-L29
Namely, you need to compile a custom openblas and install owl with the right PKG_CONFIG_PATH (it needs to be set properly only when you install owl, after that you can forget about it).
I think recompiling the openblas library and reinstalling as we do in the Dockerfile linked above is your best bet here. You could try to tweak the configure.ml file in owl to add more linking flags (e.g. -lm -lblas -llapack -llapacke -lopenblas, but it did not solve the issue on the old lts and I don’t think it will in the new one tbh).
Thank you very much for these hints!
Meanwhile I have compiled lapacke.so by hand. But for some reason I have yet to find out the LAPACKE_dlagge is not in.
Lapacke symbols are part of lapacke (a C interface for lapack), not of lapack. But in any case you need openblas, and that should provide both the lapacke and cblas symbols (and library headers) if it has been compiled with the necessary flags (default ones should be fine).
Meanwhile I have some success. I have built lapack and the liblapacke.so does now have the LAPACKE_dlagge symbol. I turned on all options and after LAPACKE_WITH_TMG=ON the symbol made it into the library.
The dockerfile that I linked has changed using some custom ad-hoc configuration that I would not recommend for general use (including the use of disable linking flag). The dockerfile that I had linked was like this one: https://github.com/owlbarn/owl/blob/0.7.2/docker/Dockerfile.ubuntu
It should be enough to set the appropriate PKG_CONFIG_PATH for your custom openblas to fix the compilation.
The Makefile is there for historical reasons, you can simply run dune build.
In any case, I am glad if you found a procedure that works for you.