Module 如何获取Ocaml中缺少的模块?
[已解决(底部)。安装quartz并通过brew重新安装x11,然后重新启动计算机。] 我正在学习Ocaml,正在浏览文档页面,需要安装一些模块(图形) 我缺少Ocaml中的Module 如何获取Ocaml中缺少的模块?,module,ocaml,opam,Module,Ocaml,Opam,[已解决(底部)。安装quartz并通过brew重新安装x11,然后重新启动计算机。] 我正在学习Ocaml,正在浏览文档页面,需要安装一些模块(图形) 我缺少Ocaml中的图形模块。在尝试将其加载到顶级(REPL right?)后,使用以下命令: 我收到错误消息: Cannot find file graphics.cma. 因此,在没有使用命令找到该文件后,我转向问题: ls `ocamlc -where`/graphics*` 我读到这意味着: 未安装图形,您必须重新安装OCaml编
图形模块。在尝试将其加载到顶级(REPL right?)后,使用以下命令:
我收到错误消息:
Cannot find file graphics.cma.
因此,在没有使用命令找到该文件后,我转向问题:
ls `ocamlc -where`/graphics*`
我读到这意味着:
未安装图形,您必须重新安装OCaml编译器
启用图形
这是否意味着每次需要新模块时都必须重新编译Ocaml?我不知道他那是什么意思
然后,我尝试使用:opam install 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.
#=== 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.
所以我做了opam depenext labblgl.1.05
在此之后,我再次尝试opam安装图形
,但失败,出现以下错误:
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.
#=== 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.
此错误表示找不到文件graphics.cma
,这让我回到了问题,以及获取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
后,我读到有必要重新启动,这就简单地解决了这个问题
之后,我可以正常运行。图形模块是基本OCaml安装的可选部分,而不是外部模块。这解释了为什么不能使用OPAM安装它。您显示的OPAM模块仅测试它是否安装在当前的OCaml系统中。它不能(因此也不尝试)将图形作为单独的模块安装
由于这个原因,安装图形(当它还没有安装时)非常棘手。安装大多数(如果不是全部)其他模块时,无需重新编译OCaml
值得一提的是,我正在运行macOS 10.12.4,并使用“opam开关”将我的OCaml系统切换到4.03.0版本。在生成的环境中,安装了图形模块,我可以在您提到的网站上运行这些示例。(例如,对于第一个例子,我看到了红色和黄色的同心圆。)
您可以尝试执行“opam开关”以切换到最新版本的编译器,并查看这是否对您有利。在过去,我很难让图形正常工作,但现在它对我来说工作得很好。图形模块是基本OCaml安装的可选部分,而不是外部模块。这解释了为什么不能使用OPAM安装它。您显示的OPAM模块仅测试它是否安装在当前的OCaml系统中。它不能(因此也不尝试)将图形作为单独的模块安装
由于这个原因,安装图形(当它还没有安装时)非常棘手。安装大多数(如果不是全部)其他模块时,无需重新编译OCaml
值得一提的是,我正在运行macOS 10.12.4,并使用“opam开关”将我的OCaml系统切换到4.03.0版本。在生成的环境中,安装了图形模块,我可以在您提到的网站上运行这些示例。(例如,对于第一个例子,我看到了红色和黄色的同心圆。)
您可以尝试执行“opam开关”以切换到最新版本的编译器,并查看这是否对您有利。过去,我很难让图形正常工作,但现在对我来说效果很好。您是否检查了以下内容:?与我在评论中给您的链接相对应,否?;-)您是否检查过:?与我在评论中给您的链接相对应,否?;-)谢谢你的帮助。我重新安装了x11并安装了quartz,然后重新启动了我的机器,这似乎可以正常工作。感谢您的帮助。我重新安装了x11并安装了quartz,然后重新启动了我的机器,这似乎可以正常工作。