为什么opam不能安装图形包?

时间:2018-02-10 01:35:48

标签: ocaml opam

我尝试安装ocaml图形包,但失败了。有关如何修复它的任何建议吗?

// ... your code
this.selectedLanguage = this.languages[0];     
console.log(this.selectedLanguage.flag);

flag:any = require("../../../assets/images/flags/"+this.selectedLanguage.flag+".png");

除了缺少的图形包,我的ocaml安装工作正常。

以下是〜/ .opam / system / build / graphics.1.0

中文件的内容

首先,graphics-14648-7afd23.err:

~/Documents/Work/Code/OCaml with graphics: opam update

=-=- Updating package repositories =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=   
[default: http] Command started
[default: http] Command started
[default] synchronized from https://opam.ocaml.org

~/Documents/Work/Code/OCaml with graphics: opam upgrade
Already up-to-date.

~/Documents/Work/Code/OCaml with graphics: opam install graphics
The following actions will be performed:
  ∗  install graphics 1.0

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=   

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=   
[graphics: ocamlc graphics.cma] Command started
[ERROR] The compilation of graphics failed at "ocamlc -custom graphics.cma -o
        test".

#=== ERROR while installing graphics.1.0 ======================================#
# opam-version         1.2.2
# os                   darwin
# command              ocamlc -custom graphics.cma -o test
# path                 /Users/Tim/.opam/system/build/graphics.1.0
# compiler             system (4.04.0)
# exit-code            2
# env-file             /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.env
# stdout-file          /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.out
# stderr-file          /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-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-14648-7afd23.info:

File "_none_", line 1:
Error: Cannot find file graphics.cma

和graphics-14648-7afd23.env:

# opam-version         1.2.2
# os                   darwin
# command              ocamlc -custom graphics.cma -o test
# path                 /Users/Tim/.opam/system/build/graphics.1.0
# compiler             system (4.04.0)
# env-file             /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.env
# stdout-file          /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.out
# stderr-file          /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.err

最终文件graphics-14648-7afd23.env为空。

1 个答案:

答案 0 :(得分:0)

编辑:这个答案没有解决OP的问题。但我认为这个答案仍然有价值,所以我把它留在这里。

使用opam switch <version number here>通过OPAM安装OCaml编译器(可用版本号由opam switch显示)。 The graphics package是一个用于检查the Graphics library可用性的虚拟包,因此如果系统的OCaml上没有库,则opam install graphics将失败。

您可以通过运行ls ~/.opam/*/lib/ocaml/graphics.cma来确认图形库的存在。如果未找到任何文件,则表示未安装Graphics,因此安装失败是有效行为。我不知道没有安装Graphics的确切原因,但也许重要的是Graphics需要安装X11。特别是,有必要在macOS上安装XQuartz。有关详细信息,请参阅Shoe's answer。此外,在此之后还需要通过OPAM重新安装OCaml。我们可以通过运行:

重新安装OCaml
opam switch reinstall <version number here>