I'm exploring NLFFI (No Longer Foreign Function Interface), its implementation in SML/NJ. The "math" example works, but "pdb" gives an error:
FFI/pdb.cm:53.5-53.21 Error: link-time exception in user program (pdb.cm):FFI/(pdb.cm):../pdbhandle.sml
DynLinkErrornlffi/lib/memory/linkage-dlopen.sml:67.26-67.40/usr/lib/smlnj/bin/sml: Fatal error -- Uncaught exception Link with 0 raised at ../cm/compile/link.sml:357.28-357.35
My shared library gives the same error. I think that the error is in "pdbhandle.sml" where dynamic linking goes, because "math" links the SML/NJ runtime library DynLinkage.main_lib
and "pdb" links its own library. I tried to load the library manually:
sml -m "\$c/internals/c-int.cm"
and
DynLinkage.open_lib { name = "./pdb.so", global = true, lazy = true };
I get
uncaught exception DynLinkError raised at: nlffi/lib/memory/linkage-dlopen.sml:67.26-67.40
DynLinkage.open_lib { name = "/usr/lib/libgmp.so.10.2.0", global =
true, lazy = true };
gives the same error.
$ ls -l /usr/lib/libgmp.so.10.2.0
-rwxr-xr-x 1 root root 488208 бер 26 01:03 /usr/lib/libgmp.so.10.2.0
I see that DynLinkError
has an argument, but SML/NJ does not show it. (BTW, is it a normal behavior?) I'm stuck here because I don't know what the error message is.