简体   繁体   中英

OCaml Graphics.open_graph “Cannot open display …”

The last line of this code

#load "graphics.cma";;
open Graphics;;
open_graph " 600x400";;

returns the following error:

Graphics.Graphic_failure "Cannot open display My-Machine.local"


Since I use Emacs 24.4 in tuareg mode, on OSX 10.9.5, I've installed XQuartz 2.7.7 and tried to tune it (looked here ).
I checked whether Graphics is properly installed (and, since all the primitives but "open_graph" work, I think it is) and looked for an answer here and there , but it doesn't really match my problem.

Any idea?

I may mention that, though I'm OK with OCaml, I'm quite new to Emacs (used to work with MacCaml) and totally ignorant about X11.

I'm no expert in any of the things you're using.

However, X11 access to the display is generally controlled by an environment variable named DISPLAY. One possibility is that yours is set to “My-Machine.local”. This doesn't look right, it just looks like the name of a machine (not a display).

For comparison, the value of DISPLAY on my Mac right now is this:

/private/tmp/com.apple.launchd.4FCqDJISx6/org.macosforge.xquartz:0

If this is meaningful (which it might be), it suggests you need to make sure the value of DISPLAY gets plumbed properly through to X11.

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