【发布时间】:2017-11-19 18:57:50
【问题描述】:
[已解决(在底部)。安装石英并通过 brew 重新安装 x11 然后重新启动机器。]
我正在学习 Ocaml,正在浏览 these 文档页面,需要安装一些模块(图形)。
我在 Ocaml 中缺少一个 Graphics 模块。在尝试将其加载到顶层(REPL 对吗?)后:
$ ocaml
OCaml version blahblah
# #load "graphics.cma";;
# open Graphics;;
我收到错误消息:
Cannot find file graphics.cma.
所以我徘徊到this 问题并没有找到带有命令的文件:
ls `ocamlc -where`/graphics*`
我读到这意味着:
图形未安装,您必须重新安装 OCaml 编译器 启用图形。
这是否意味着每次需要新模块时都必须重新编译 Ocaml?我不确定他的意思。
然后,我尝试使用:opam install graphics 安装 Graphics。
我收到了这个错误:
This package relies on external (system) dependencies that may be missing. `opam depext lablgl.1.05' may help you find the correct installation for your system.
所以我做了opam depext lablgl.1.05
在此之后,我再次尝试opam install graphics,但失败并出现此错误:
#=== ERROR while installing graphics.1.0 ======================================#
# opam-version 1.2.2
# os darwin
# command ocamlc -custom graphics.cma -o test
# path /Users/alexanderkleinhans/.opam/system/build/graphics.1.0
# compiler system (4.02.2)
# exit-code 2
# env-file /Users/alexanderkleinhans/.opam/system/build/graphics.1.0/graphics-24451-7afd23.env
# stdout-file /Users/alexanderkleinhans/.opam/system/build/graphics.1.0/graphics-24451-7afd23.out
# stderr-file /Users/alexanderkleinhans/.opam/system/build/graphics.1.0/graphics-24451-7afd23.err
### stderr ###
# File "_none_", line 1:
# Error: Cannot find file graphics.cma
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions failed
∗ install graphics 1.0
No changes have been performed
=-=- graphics.1.0 troubleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> This package checks whether the Graphics library was compiled.
这个错误提示Cannot find file graphics.cma,这让我回到了this 问题以及获取graphics.cma(以及我可能需要的其他模块)的步骤。
我虽然 opam 是 ocaml 的包管理器(这个安装模块对吗?)
编辑:
我使用了brew info ocaml 并使用x11 进行了安装,所以我认为这意味着我应该拥有它...
ocaml: stable 4.04.1 (bottled), devel 4.05.0+beta3, HEAD
General purpose programming language in the ML family
https://ocaml.org/
/usr/local/Cellar/ocaml/4.04.1 (1,730 files, 194.4MB) *
Poured from bottle on 2017-06-13 at 15:23:43
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ocaml.rb
==> Requirements
Optional: x11 ✘
==> Options
--with-flambda
Install with flambda support
--with-x11
Install with the Graphics module
--devel
Install development version 4.05.0+beta3
--HEAD
Install HEAD version
编辑 2:
跑步
brew install Caskroom/cask/xquartz
brew reinstall ocaml --with-x11
允许我编译,但运行给了我这个致命的异常。好像是 X11 的东西?
Fatal error: exception Graphics.Graphic_failure("Cannot open display ")
已解决
So I think the two steps that were necessary were to make sure ocaml was installed with X11. Note that `brew info ocaml` seemed to give wrong information (said it was installed with X11 but reinstall was necessary). On OSX, I also needed to install quarts.
brew install Caskroom/cask/xquartz
brew reinstall ocaml --with-x11
在此之后我可以编译,但执行时出错。这只是通过重新启动来解决,我在安装xquartz 后阅读是必要的。
之后我就可以正常运行了。
【问题讨论】:
-
哪个对应我在评论中给你的链接,不是吗? ;-)