Ocaml Unbound Graphics Module

纵饮孤独 提交于 2019-11-26 17:13:53

问题


Running

open Graphics;;

in ocaml returns an error, saying it is an unbound module. Running it in terminal (ocaml) returns the same thing.

Does this mean my Graphics Module was somehow not installed with the ocaml package? If so, how can I install the module?

On Fedora.


回答1:


Graphics module is not ready by default. You need to load it manually. In toplevel:

$ ocaml
       OCaml version blahblah
# #load "graphics.cma";;
# open Graphics;;

or you can specify it at the command line:

$ ocaml graphics.cma
       OCaml version blahblah
# open Graphics;;

I do not know about Fedora but if the above fails, graphics is not really installed in your environment.




回答2:


This error also appears often on Mac OS X. With Homebrew this module is disabled by default on installation, so brew install ocaml will not install the Graphics module, probably due to the XQuartz dependency.

If you run brew info ocaml, it will tell you that there's a flag, namely --with-x11, that will "Install with the Graphics module". So to install/reinstall ocaml you'll have to run:

brew install Caskroom/cask/xquartz
brew [re]install ocaml --with-x11

Finally remember to check that the instance of ocaml that is running is the one in /usr/local/Cellar/objective-caml/x.yy.z[_w]/bin, and if it isn't then prepend that url to your PATH environment variable. Also remember to restart your computer after the XQuartz installation.



来源:https://stackoverflow.com/questions/18435927/ocaml-unbound-graphics-module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!