2017-06-16 5 views
0

[解決済み(底部)。私はOcamlを勉強しており、these文書ページを通過しており、いくつかのモジュール(グラフィックス)をインストールする必要があります。Ocamlで不足しているモジュールを取得するには?

OcamlにGraphicsモジュールがありません。でトップレベル(?REPLの右側)にそれをロードしようとした後:

$ ocaml 
     OCaml version blahblah 
# #load "graphics.cma";; 
# open Graphics;; 

私は、エラーメッセージが表示されます:

Cannot find file graphics.cma. 

だから私はthisの質問にとして、ファイルを見つけていない後にオーバーさまよいますコマンド:

ls `ocamlc -where`/graphics*` 

私はこれがあることを意味することをお読みください。

Graphics is not installed and you have to reinstall OCaml compiler enabling Graphics.

これは、新しいモジュールが必要なたびにOcamlを再コンパイルする必要があることを意味しますか?彼はそれが何を意味するのか分かりません。

次に、グラフィックをインストールしようとしました:opam install graphics

私はこのエラーを得た:だから私はこの後opam depext lablgl.1.05

をした

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 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(および他のmodu私がそれらを必要とするかもしれないのでles)。

私もopam(これは右のモジュールをインストールする?)OCamlのためのパッケージマネージャだった

EDIT:

私はbrew info ocamlを行なったし、これは私がそれを持っている必要があります意味かかわらず、私はそうx11とIをインストールしました。..

実行

:。

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 

EDIT

brew install Caskroom/cask/xquartz 
brew reinstall ocaml --with-x11 

私はコンパイルできますが、実行するとこの致命的な例外が発生しました。 X11のように見えますか?

Fatal error: exception Graphics.Graphic_failure("Cannot open display ") 

は、私はコンパイルが、実行時にエラーが発生しましたCOULDこの後

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の再起動によって単純に解決されました。

その後、私は正常に動作することができました。

+0

これをチェックしましたか:https://stackoverflow.com/questions/40903406/not-getting-graphics-even-when-reinstalled-ocaml-mac-os-x? – Lhooq

+0

私はあなたがコメントであなたに与えたリンクに相当しますか? ;-) – Lhooq

答えて

2

グラフィックスモジュールは、外部モジュールではなく、ベースOCamlインストールのオプション部分です。 OPAMを使用してインストールできない理由を説明します。表示するOPAMモジュールは、現在のOCamlシステムにであるかどうかだけをテストしています。グラフィックスを別のモジュールとしてインストールすることはできません(したがって、試行しません)。

このため、グラフィックをインストールする前に(まだインストールされていない場合)、グラフィックスをインストールするのが普通ではありません。 OCamlを再コンパイルする必要はありません。

私はmacOS 10.12.4を実行しています。私はOCamlシステムを4.03.0リリースに切り替えるために "opam switch"を使いました。結果として得られる環境では、Graphicsモジュールがインストールされているので、あなたが言及したWebサイトで例を実行するのに問題はありません。 (最初は同心円の赤と黄色の円が表示されます)

"opam switch"を使ってコンパイラの最新バージョンに切り替えると、これがうまくいくかどうかが分かります。過去に私はグラフィックをうまく動作させるのに苦労しましたが、今は私にとって素晴らしい仕事です。

+0

助けてくれてありがとう。私はx11を再インストールし、石英をインストールしてから、マシンを再起動して、動作するように見えました。 – 1N5818

関連する問題