简体   繁体   English

OCaml 图形错误未绑定模块 mac OSX

[英]OCaml Graphics Error Unbound module mac OSX

I'm on OSX 10.11.6 (and sometimes 10.13.6).我在 OSX 10.11.6(有时是 10.13.6)上。 I've done the following (per https://stackoverflow.com/a/29609483/2630028 ):我已经完成了以下操作(根据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.不幸的是, ocaml brew 公式不再有--with-x11标志。 I tried to follow this doc: https://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Modules-and-open .我试图遵循这个文档: https://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Modules-and-open

In utop :utop

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

In a foo.ml file在 foo.ml 文件中

open Graphics;;

and running ocamlbuild foo.native :并运行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 ).您可能需要使语法适应您的 shell(此处为bash )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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