Ocaml's Graphics.open_graph does not work

允我心安 提交于 2019-12-24 13:39:18

问题


I am trying to follow the ocaml manual to draw something. But here is a strange response from Ocaml's toplevel. Anyone sees why? Thanks.

# #load "graphics.cma";;
# Graphics.open_graph "foo:0";;
_X11TransSocketINETConnect() can't get address for foo:6000: nodename nor servname provided, or not known
Exception: Graphics.Graphic_failure "Cannot open display foo:0".

回答1:


I use Graphics.open_graph " 600x400", and it works. Note the space before the resolution specification.

As to why foo:0 would or would not work, that is not OCaml-specific but something about the X11 server. You probably don't need to, and therefore don't want to, use such specialized feature (opening a window on another display).




回答2:


foo term is a common way to specify parts of examples that should be substituted by the user to match local environment. In your case you probably want to read 3 lines below and open default display :

Graphics.open_graph ""

connects to the default display and creates a window with the default geometry.



来源:https://stackoverflow.com/questions/11168532/ocamls-graphics-open-graph-does-not-work

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