Here's roughly what I have:
lib.c: contains function "myCfunction"
lib.ml: external myfunction : string -> int = myCfunction, class
myclass
test.ml: uses Lib.myclass and Lib.myfunction
How do I build lib.c and lib.ml into lib.cmxa, and then compile it with
test.ml? I've been trying for a few hours and I get various different
errors. One example:
$ ocamlopt -o test ocaml-lib.cmxa lib.ml lib.c test.ml -cclib -lC-lib
lib.o: In function `myCfunction':
lib.c:(.text+0x0): multiple definition of `myCfunction'
lib.o:lib.c:(.text+0x0): first defined here
/tmp/camlstartupd80bc7.o: In function `caml_program':
: undefined reference to `camlMl3d__entry'
/tmp/camlstartupd80bc7.o: In function `caml_globals':
: undefined reference to `camlMl3d'
...
collect2: ld returned 1 exit status
Error during linking