Addem
Addem

Reputation: 3949

OCaml: How do I compile/make a program which has file extensions .ml.x?

I have downloaded a project which contains the following files:

assert.mli
assert.ml
deque.ml
deque.mli
eventloop.ml
eventloop.mli
g.ml
gctx.ml
gctx.mli
gdemo.html
gdemo.ml
gdemo.mli
g-js.ml.x
g-native.ml.x
lightbulb.html
lightbulb.ml
lightbulb.mli
Makefile
paint.html
paint.ml
paint.mli
widget.ml
widget.mli
widgetTest.ml
widgetTest.mli

I can compile some of the files that do not depend on other files by doing

$ ocamlc assert.mli assert.ml

for instance. However, eventloop.ml depends on widget.ml and widget.ml depends on gctx.ml. gctx seems to depend on a module G which I believe is a graphics library. When I peek inside g-js.ml.x I see it confirmed that this file is importing a fixed version of the graphics library. However, I have no clue how to use this file. I tried a few guesses in the terminal but to no avail. One example guess was

$ ocamlc g-js.ml.x g.ml

I tried googling "how to compile ocaml ".ml.x"" but didn't come up with anything and I'm not sure if I should be searching for anything else, or if there just isn't much out there about how to handle these files.

I also tried in the terminal $ make -f Makefile and got the error

+ ocamlfind ocamldep -package js_of_ocaml-lwt.graphics -package js_of_ocaml-lwt -package js_of_ocaml -modules gdemo.mli > gdemo.mli.depends
ocamlfind: Package `js_of_ocaml-lwt.graphics' not found
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
Makefile:51: recipe for target 'gdemo.byte' failed
make: *** [gdemo.byte] Error 10 

Looking up this error, other people found it fixed by updating OPAM's libraries and especially updating cppo_ocamlbuild but that didn't fix it for me.


Edit: After following some instructions in the comments, I get a new error message when trying to make the Makefile:

rm -rf g.ml
cp g-js.ml.x g.ml
ocamlbuild -use-ocamlfind -pkg js_of_ocaml -pkg js_of_ocaml-lwt -pkg js_of_ocaml-lwt.graphics gdemo.byte
Failure: ocamlfind not found on path, but -no-ocamlfind not used.
Compilation unsuccessful after building 0 targets (0 cached) in 00:00:00.
Makefile:51: recipe for target 'gdemo.byte' failed
make: *** [gdemo.byte] Error 2

Upvotes: 0

Views: 264

Answers (0)

Related Questions