owlbarn / owl

Owl - OCaml Scientific Computing @ https://ocaml.xyz
MIT License
1.2k stars 120 forks source link

Can't build a module using Owl_stats_dist in dune, works in utop (arm64 mac) #626

Open anentropic opened 1 year ago

anentropic commented 1 year ago

This is weird

I have a module that has this code

let point () =
  Gg.V3.v
    (Owl_stats_dist.std_uniform_rvs ())
    (Owl_stats_dist.std_uniform_rvs ())
    (Owl_stats_dist.std_uniform_rvs ())

This works fine in dune utop for same project:

utop # # require "owl";;

utop # Owl_stats_dist.std_uniform_rvs ();;
- : float = 0.815008172023810484

But when I try to build my module with dune I get:

Undefined symbols for architecture arm64:
  "_sfmt_state", referenced from:
      _owl_stub_std_uniform_rvs in libowl_stubs.a(owl_stats_dist_stub.o)
      _owl_stub_uniform_int_rvs in libowl_stubs.a(owl_stats_dist_stub.o)
      _beta_rvs in libowl_stubs.a(owl_stats_dist_beta.o)
      _binomial_rvs in libowl_stubs.a(owl_stats_dist_binomial.o)
      _dirichlet_rvs in libowl_stubs.a(owl_stats_dist_dirichlet.o)
      _std_exponential_rvs in libowl_stubs.a(owl_stats_ziggurat.o)
      _std_gaussian_rvs in libowl_stubs.a(owl_stats_ziggurat.o)
      ...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
File "caml_startup", line 1:
Error: Error during linking (exit code 1)

Seems strange that it should work in utop but not in dune?

I have owl 1.1.0 pinned to github due to #625

anentropic commented 1 year ago

Also... is Owl_stats_dist.std_uniform_rvs the best method for getting a single random float from uniform distribution? It's the one I found