0

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
Addem
  • 3,635
  • 3
  • 35
  • 58
  • 1
    Did you check that the subpackage `js_of_ocaml-lwt.graphics` is installed with `ocamlfind query js_of_ocaml-lwt.graphics`? Otherwise, the extension `.x` probably indicates that the file is preprocessed with a custom preprocessor (and it is impossible to guess what is this preprocessor from the available information). – octachron Mar 17 '19 at 18:23
  • @octachron the query did not find the subpackage so I installed it. However, it doesn't seem to have changed any of the error messages. – Addem Mar 17 '19 at 18:53
  • Do you have the same error when running `ocamlfind ocamldep -package js_of_ocaml-lwt.graphics -package js_of_ocaml-lwt -package js_of_ocaml -modules gdemo.mli > gdemo.mli.depends` independently? – octachron Mar 17 '19 at 19:49
  • @octachron So I'm a little unclear on exactly which "half" of the errors this is intended to resolve. I ran this command and then ran `make -f Makefile` and got an error complaining about a pre-compiled file from gdemo (presumably created by the command that you wrote above). If that's not the error this is trying to fix, I tried running `ocamlc g-js.ml.x g.ml` and it just doesn't know what I'm trying to do. – Addem Mar 18 '19 at 00:02
  • Like I said your *.x files require to be preprocessed before being compiled. The preprocessing step should be detailled in the Makefile. You should update the error message to reflect the new one. – octachron Mar 18 '19 at 08:33
  • @octachron I don't know what preprocessing means in this context. Glancing at the Makefile, I don't know enough OCaml to make heads or tails of what it's doing. So I still am not sure how I can and should use these files, either by compiling them one at a time or by using the Makefile. In any case, I'll add the new error message. – Addem Mar 18 '19 at 22:34
  • The new error message is stating that you have a path problem: ocamlfind is not available from the make invocation. How did you install OCaml? What instruction did you follow? Note that https://discuss.ocaml.org might be a better help forum. – octachron Mar 18 '19 at 23:41
  • @octachron It's been a while since I installed but I believe I installed OPAM and then used that to install. I likely just tried to follow these instructions: http://www.ocaml.org/docs/install.html and followed the Ubuntu instructions (using Linux Mint). – Addem Mar 19 '19 at 04:26
  • If you have opam installed, you can switch your opam version (for example to the last version `opam switch create 4.07.1` if your opam version is < 2 or `opam switch 4.07.1` otherwise. Then, you would be using an opam-managed ocaml, and it would be easier to manage the state of your installation. – octachron Mar 19 '19 at 16:30

0 Answers0