【问题标题】:Unbound module Graphics Ocaml on Linux mintLinux mint 上的未绑定模块 Graphics Ocaml
【发布时间】:2020-07-24 11:55:15
【问题描述】:

我已经阅读了多个相同的问题,但答案并没有解决它。 OCaml 顶层,版本 4.11.0+dev0-2019-10-18 opam 列表

# Packages matching: installed
# Name              # Installed # Synopsis
base-bigarray       base
base-threads        base
base-unix           base
conf-libX11         1           Virtual package relying on an Xlib system instal
conf-pkg-config     1.1         Virtual package relying on pkg-config installati
dune                2.4.0       Fast, portable, and opinionated build system
dune-configurator   2.4.0       Helper library for gathering system configuratio
dune-private-libs   2.4.0       Private libraries of Dune
graphics            5.1.0       The OCaml graphics library
ocaml               4.10.0      The OCaml compiler (virtual package)
ocaml-base-compiler 4.10.0      Official release 4.10.0
ocaml-config        1           OCaml Switch Configuration

opam 安装图形 [注意] 图形包已安装(当前版本为 5.1.0)。

ocamlfind query -predicates native -a-format graphics

ocamlfind: Package `graphics' not found
me@2020:~$   /home/ivg/.opam/fresh/lib/ocaml/graphics.cmxa
bash: /home/ivg/.opam/fresh/lib/ocaml/graphics.cmxa: Aucun fichier ou dossier de ce type

ocamlfind ocamlopt -package graphics

ocamlfind: Package `graphics' not found

ls ocamlc -where/graphics*

ls: impossible d'accéder à '/usr/local/lib/ocaml/graphics*': Aucun fichier ou dossier de ce type

sudo apt install libx11-dev

Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances       
Lecture des informations d'état... Fait
libx11-dev est déjà la version la plus récente (2:1.6.4-3ubuntu0.2).
0 mis à jour, 0 nouvellement installés, 0 à enlever et 8 non mis à jour.

不明白怎么回事,好像安装了但是不能正常使用?

ocamlc graphics.cma test1.ml -o test1

File "test1.ml", line 3, characters 5-13:
3 | open Graphics;;
         ^^^^^^^^
Error: Unbound module Graphics

【问题讨论】:

    标签: graphics compilation ocaml libraries unbound


    【解决方案1】:

    来自https://caml.inria.fr/

    从 OCaml 4.09 开始,图形库作为外部分发 包。

    因此您必须使用 -I 选项和 ocamlfind 指定 ocamlc 在哪里可以找到相应的 cma 文件强>:

    ocamlc -I $(ocamlfind query graphics) graphics.cma test1.ml -o test1
    

    使用 utop 您必须先从指令 #require "graphics";; 开始,然后再执行 open Graphics;;

    【讨论】:

    • opam list conf-libX11 1 conf-m4 conf-pkg-config cppo dune dune-configurator dune-private-libs graphics 5.1.0 ocaml 4.10.0 ocaml-base-compiler 4.10.0 ocaml-配置 1 ocamlbuild 0.14.0 ocamlfind 1.8.1 topkg 1.0.1 utop 2.4.3 zed 2.0.7 $ utop La commande « utop » n'a pas été trouvée, mais peut être installée avec : sudo apt install utop
    • 是的;我宁愿重新安装 ocaml4.08 以保持安静。但很难卸载它。 sudo apt-get purge --auto-remove opam* Le paquet « opam » n'est pas installé, et ne peut donc être supprimé 0 mis à jour, 0 nouvellement installés, 0 à enlever et 8 non mis à jour. opam uninstall ocaml 无法满足您的要求:- ocaml-base-compiler 包是此编译器基础的一部分,无法更改 未找到解决方案,正在退出
    猜你喜欢
    • 2013-08-28
    • 1970-01-01
    • 2013-09-19
    • 2016-01-16
    • 1970-01-01
    • 2012-11-21
    • 1970-01-01
    • 2020-04-18
    • 1970-01-01
    相关资源
    最近更新 更多