romerun
romerun

Reputation: 2211

ocaml top level and native library

I have a library that calls C code. It's compile with the -custom, -cclib, -l flags, which is working ok when I compile my code against the library with ocamlc,

but when I use the "ocaml" top level to run a script like:

ocaml -I /opt/godi/lib/ocaml/pkg-lib/xxxx xxx.cma myprog.ml

it says:

Error: The external function `caml_yyyy' is not available

Do I need additional parameters to tell the top level ?

Upvotes: 3

Views: 725

Answers (2)

Fabrice Le Fessant
Fabrice Le Fessant

Reputation: 4274

You should build your own toplevel using "ocamlmktop":

$ ocamlmktop -custom -I /opt/godi/lib/ocaml/pkg-lib/xxxx xxx.cma -o ocaml_with_xxx

Then, you can use it :

$ ./ocaml_with_xxx -I /opt/godi/lib/ocaml/pkg-lib/xxxx

Note that you still need the -I so that the toplevel can find the interface files of the library that it contains.

Upvotes: 3

ygrek
ygrek

Reputation: 6697

IIRC you cannot use libraries compiled with -custom in toplevel. You should compile dynamically-loadable stubs so that toplevel could pick up them. This is very easy to do with e.g. oasis and somewhat more involved if invoking ocaml tools manually.

Upvotes: 2

Related Questions