OCaml - Cannot find graphics.cma

放肆的年华 提交于 2019-12-06 06:40:29

First of all, check Graphics is really installed. This library is optional and therefore it may not be installed. There are several ways to check but the following should work for any situation:

$ ls `ocamlc -where`/graphics*

If there is no file listed by the above command, Graphics is not installed and you have to reinstall OCaml compiler enabling Graphics.

If files like graphics.cma are there, then you have to show us how you try to compile your code with Graphics. The best answer varies depending on how you compile: inside toplevel, hand compiling with ocamlc, or with some build tool like ocamlbuild.

The solution mostly depends on how are you compiling. If you're using ocamlbuild tool, the the following would be sufficient:

ocamlbuild -use-ocamlfind -pkg graphics my_program.native

Where my_program.native is your target. Note, you can try to omit the -use-ocamlfind flag.

In order to bring graphics to your toplevel, the easiest solution would be to use topfind:

# #use "topfind";;
# #require "graphics";;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!