lwt icon indicating copy to clipboard operation
lwt copied to clipboard

dlopen cannot locate symbol "lwt_unix_not_available; cannot locate symbol "caml_unix_cloexec_default

Open KoviRobi opened this issue 10 months ago • 2 comments

I have encountered an issue on Android similar to #664 that stops UTop from being able to open (I have a workaround)

neofetch system details
❯ neofetch --stdout
u0_a345@localhost
-----------------
OS: Android 11 aarch64
Host: Lenovo Lenovo L79031
Kernel: 4.19.136-perf+
Uptime: 6 days, 9 hours, 29 mins
Packages: 468 (dpkg), 1 (pkg)
Shell: zsh 5.9
Resolution: 2192x996
WM: i3
Terminal: tmux
CPU: Qualcomm KONA (8) @ 1.804GHz
Memory: 6534MiB / 15733MiB

I have put my notes to get OCaml working on my Android/termux at https://gist.github.com/KoviRobi/9361a808c5543e57b68d531553269dba -- see https://gist.github.com/KoviRobi/9361a808c5543e57b68d531553269dba#file-04-utop-build-md for the LWT patch I applied.

But including it here for ease:

I can install utop via opam fine, but when I try to run it, I get

❯ utop
Fatal error: cannot load shared library dlllwt_unix_stubs
Reason: dlopen failed: cannot locate symbol "caml_unix_cloexec_default" referenced by "/data/data/com.termux/files/home/pdev/ocaml/.install/share/opam/default/lib/stublibs/dlllwt_unix_stubs.so"...

Some minor grep pointed me towards

patchelf --add-needed $OPAMROOT/default/lib/ocaml/stublibs/dllunixnat.so \
  $OPAMROOT/default/lib/stublibs/dlllwt_unix_stubs.so

Which then needed me to

❯ utop
Fatal error: cannot load shared library dlllambda_term_stubs
Reason: dlopen failed: cannot locate symbol "lwt_unix_not_available" referenced by "/data/data/com.termux/files/home/pdev/ocaml/.install/share/opam/default/lib/stublibs/dlllambda_term_stubs.so"...

so I did

patchelf --add-needed $OPAMROOT/default/lib/stublibs/dlllwt_unix_stubs.so \
  $OPAMROOT/default/lib/stublibs/dlllambda_term_stubs.so

And now I have a working utop! But I feel like there's a much better fix to this, i.e.at build time of dlllwt_unix_stubs/dlllambda_term_stubs there's a linker flag missing that would add those NEEDED entries, rather than having to patch it up after. I just don't know enough about the OCaml ecosystem/LWT build steps to know what.

Hopefully there's an easy fix, if not, it's work-aroundable, and perhaps this/my gist for building OCaml on Android will help other Android users.

KoviRobi avatar Feb 02 '25 22:02 KoviRobi

hiya,

thanks for the report!

i don't know if that's an issue with lwt or lambdaterm/utop, i'll look into it when i have the time but i don't know when that will be

raphael-proust avatar Feb 07 '25 08:02 raphael-proust

No worries I get how it is, I've got a workaround for now anyway :)

KoviRobi avatar Feb 07 '25 11:02 KoviRobi