1

I need to convert a simple OCaml file into JAR file so that I can run atop JVM platform.

This OCaml file needs to use the Big_int module. There is this line of code

open Big_int

But it always returns me this line of error Error: Reference to undefined globalBig_int'` when I try to run ocamljava to convert it into jar file.

ocamljava -o myprog.jar source.ml

I am able to see big_int.cmi, big_int.cmj, big_int.cmx, big_int.mli, nums.cma, nums.cmja, etc on this directory /Users/myname/.opam/ocamljava-2.0-alpha2/lib/ocaml. I know that the Big_int is residing inside these libraries; but I don't know how to link them into compilation.

By the way, I'm using OCamlJava 2.0.

nlucaroni
  • 47,556
  • 6
  • 64
  • 86
Erencie
  • 391
  • 2
  • 3
  • 12

2 Answers2

0

Erencie,

Entering open Big_int only accesses the compiled interface (.cmi file) for big_int, but does not load the implementation of big_int.

Implementations for user modules can be entered with the #load directive.

In your case, you want to do the following:

   #load "file-name";;

This is going to load in memory a bytecode object file (.cmo file) or library file (.cma file) produced by the batch compiler ocamlc.

Thus you should do the following:

   #load "big_int.cmo";;

If the object file for big_int does not exist yet, you should compile big_int.ml first.

Please let me know if you have any questions!

Devarsh Desai
  • 5,984
  • 3
  • 19
  • 21
0

You should probably add the "nums" library to the command-line, as in:

ocamljava nums.cmja source.ml

Also note that the implementation of "nums" in OCaml-Java has been only lightly tested, and may contain bugs. If you encounter a bug, it would be nice to report it at https://github.com/xclerc/ocamljava.

xclerc
  • 1