[英]Unbound module Graphics Ocaml on Linux mint
i have read multiple identical problem but answers dont fix it.我已经阅读了多个相同的问题,但答案并没有解决。 The OCaml toplevel, version 4.11.0+dev0-2019-10-18 opam list
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 install graphics [NOTE] Package graphics is already installed (current version is 5.1.0). opam install graphics [注意] Package 图形已安装(当前版本为 5.1.0)。
ocamlfind query -predicates native -a-format graphics 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 ocamlopt - 包图形
ocamlfind: Package `graphics' not found
ls ocamlc -where
/graphics* ls
ocamlc -where
/图形*
ls: impossible d'accéder à '/usr/local/lib/ocaml/graphics*': Aucun fichier ou dossier de ce type
sudo apt install libx11-dev 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.
I dont understand what is wrong, it seems to be installed but it cant use it properly?我不明白出了什么问题,它似乎已安装但无法正常使用?
ocamlc graphics.cma test1.ml -o test1 ocamlc graphics.cma test1.ml -o test1
File "test1.ml", line 3, characters 5-13:
3 | open Graphics;;
^^^^^^^^
Error: Unbound module Graphics
From https://caml.inria.fr/ :从https://caml.inria.fr/ :
Since OCaml 4.09, the graphics library is distributed as an external package.
从 OCaml 4.09 开始,图形库作为外部 package 分发。
Hence you have to specify to ocamlc where to find the corresponding cma file using the -I option and ocamlfind :因此,您必须使用-I选项和ocamlfind向ocamlc指定在哪里可以找到相应的cma文件:
ocamlc -I $(ocamlfind query graphics) graphics.cma test1.ml -o test1
Using utop you will have to start with the directive #require "graphics";;
使用utop您必须从指令
#require "graphics";;
开始。 before doing open Graphics;;
在做
open Graphics;;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.