2

I'm on OSX 10.11.6 (and sometimes 10.13.6). I've done the following (per https://stackoverflow.com/a/29609483/2630028):

brew install Caskroom/cask/xquartz
brew install ocaml
brew install pkg-config
brew install opam
opam install utop
opam install graphics

All commands are successful. Unfortunately there is no longer a --with-x11 flag with the ocaml brew formula. I tried to follow this doc: https://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Modules-and-open.

In utop:

utop # #load "graphics.cma";;
Cannot find file graphics.cma.

In a foo.ml file

open Graphics;;

and running ocamlbuild foo.native:

File "foo.ml", line 1, characters 5-13:
1 | open Graphics;;
         ^^^^^^^^
Error: Unbound module Graphics
Command exited with code 2.

Is there any way to get this working without having to build from source?

solstice333
  • 3,399
  • 1
  • 31
  • 28
  • Installing ocaml compiler via opam will be the most reliable. The system switches (ocaml compilers provided by macports, homebrew, apt, etc) have been discouraged for quite some time now since they can have some issues like the one you are seeing. – Anurag Soni Dec 30 '19 at 17:04

1 Answers1

0

Have you tried something like this?

utop -I $(ocamlfind query graphics)

It worked for me. You may need to adapt the syntax to your shell (here bash).

cuihtlauac
  • 1,808
  • 2
  • 20
  • 39
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/27649018) – Matthias Nov 18 '20 at 16:45
  • 1
    @Matthias It does answer the question. It might be very short, but that's not a reason to delete it. See [this post](https://meta.stackoverflow.com/q/287563/4284627) by a moderator. – Donald Duck Nov 18 '20 at 17:34
  • 1
    It doesn't sound like an answer. "have you tried ...?" sounds like requesting clarification and that should be in a comment. If this question really answers the question then it's fine and subsequent reviewers might not request deletion. – Matthias Nov 19 '20 at 06:43
  • @Matthias you're correct. I initially forgot to explicitly say my answer works, at least on my machine. Without this being an answer is questionable, agreed. – cuihtlauac Nov 19 '20 at 07:25
  • 1
    Thanks for the edit. I would retract my vote for closing this answer, but the system doesn't let me. Nevertheless, I don't think anyone else will now vote to close this answer, so everything should be fine. – Matthias Nov 19 '20 at 08:51