简体   繁体   中英

OCaml Graphics Error Unbound module mac OSX

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?

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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM