OWL - undefined symbols after standard installation


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

However as soon as I try to open a package an error is thrown that undefines symbol is referenced:

Cannot load required shared library dllowl_stubs.
eason: /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.*

I guess it has to do with library version of lapacke. Does anyone knows what to do to make this installation work correctly?

Does this happen when you’re loading it in a toplevel only? Did you try to write a simple application and run it?

It happens when I start it in ocaml toplevel.

#use “topfind”
#require “owl”
open Owl

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

Same happens when I do:

ocamlfind ocamlc -linkpkg -package owl s.ml

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

What a bummer liblapacke.so does not contain the symbol LAPACKE_dlagge

It seems to be part of LAPACK 3.8.0
whereas the installed version is 3.7.1-4ubuntu1
and now?

Neither does mine, but everything works fine for me. Mine version is 3.6.0-2ubuntu2

Is it possible that you have several installations of LAPACK on your system (maybe you’ve installed some manually in the /usr prefix)?

Update: And a quick search says, that dlagge was there for long time, however, it is not in liblapack.so but in liblapacke.so (liblapacke.a).

Mine is in

Ok, so, let’s double check that (a) the cma file has the reference to lapacke, e.g.,

ocamlobjinfo $(ocamlfind query owl)/owl.cma | grep object

which should output something like this:

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

a) is as in your system

b) /usr/lib/lapacke.so is not there and the one in
does not have the symbol

ldconfig -p | grep lapack
liblapacke.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/liblapacke.so.3
liblapacke.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/liblapacke.so
liblapack.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/liblapack.so.3
liblapack.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/liblapack.so

Ok, so this is the crux of the problem :slight_smile: 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).

You can also look into this issue https://github.com/owlbarn/owl/issues/354
or maybe @mseri will drop in and help us :slight_smile:

1 Like

Thank you.
Mint is using the Ubuntu packages.
Then I will try to build lapack by hand.

Thanks for pinging me.

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).

There used to be a related issue on launchpad but I could not find it, so maybe my memory is failing me. There is still the issue that openblas on ubuntu does not ship lapacke.h.

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.

A hint that it might depend on libopenblas-dev…

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.

1 Like

This helped me to compile owl against custom openblas:


Looking at Dockerfile I first tried


But linker could not find openblas libraries

1 Like

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.