OCaml graphics relies on X11. Out of the box 10.9 lacks X11. This site provides an ‘Apple approved’ version of X11 called “XQuartz”.
The shell command “ocamlmktop -o mytop graphics.cma” is necessary for OCaml graphics. As shipped it cannot find libX11.6.dylib. as explained here where we propose adding “export DYLD_LIBRARY_PATH=/opt/X11/lib” to the file .bash_profile . In 10.9, however, that addition causes XQuartz to fail.
Here is an awkward workaround:
ocamlmktop -o ~/bin/ocamlg graphics.cmaThis should place a top level OCaml interpreter with the graphics functions where the shell command beginning ocamlg launches the interpreter but only in a shell launched while the export command is in .bash_profile.
ocamlmktop -o mytop graphics.cma ocamlmktop -o mytop -dllpath /opt/X11/lib graphics.cma ocamlmktop -o mytop -dllpath /opt/X11 graphics.cma ocamlmktop -o mytop -dllpath /opt/X11/lib/libX11.6.dylib graphics.cmaThe error message is:
File "_none_", line 1: Error: Error on dynamically loaded library: /usr/local/lib/ocaml/stublibs/dllgraphics.so: dlopen(/usr/local/lib/ocaml/stublibs/dllgraphics.so, 138): Library not loaded: /opt/local/lib/libX11.6.dylib Referenced from: /usr/local/lib/ocaml/stublibs/dllgraphics.so Reason: image not found
This is useful.