简体   繁体   English

OCaml 未绑定图形模块

[英]OCaml Unbound Graphics Module

Running跑步

open Graphics;;

in OCaml returns an error, saying it is an unbound module.在 OCaml 中返回一个错误,说它是一个未绑定的模块。 Running it in terminal (ocaml) returns the same thing.在终端 (ocaml) 中运行它会返回相同的结果。

Does this mean my Graphics Module was somehow not installed with the OCaml package?这是否意味着我的图形模块没有安装 OCaml 包? If so, how can I install the module?如果是这样,我该如何安装模块?

On Fedora.在 Fedora 上。

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.这个错误也经常出现在 Mac OS X 上。 使用 Homebrew 这个模块在安装时默认是禁用的,所以brew install ocaml不会安装 Graphics 模块,可能是由于 XQuartz 依赖。

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".如果您运行brew info ocaml ,它会告诉您有一个标志,即--with-x11 ,它将“与图形模块一起安装”。 So to install/reinstall ocaml you'll have to run:因此,要安装/重新安装 ocaml,您必须运行:

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.最后记得检查正在运行的ocaml实例是否是/usr/local/Cellar/objective-caml/x.yy.z[_w]/bin中的实例,如果不是,则将该网址添加到您的PATH环境变量。 Also remember to restart your computer after the XQuartz installation.还要记住在安装 XQuartz 后重新启动计算机。

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.我不了解 Fedora,但如果上述操作失败,则说明您的环境中并未真正安装图形。

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

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