简体   繁体   English

如何编译ocaml图形Windows Cygwin

[英]How to compile ocaml graphics windows cygwin

I use cygwin 64 terminal on Windows and want to compile this ocaml graphics code. 我在Windows上使用cygwin 64终端,并希望编译此ocaml图形代码。 It's saved as a .ml type: 它保存为.ml类型:

let etat x y c=draw_circle x y 10 ;let a=(x-5) and b=(y-5) in moveto a b ;let s=string_of_int c in draw_string s;;
etat 100 100 1;;
etat 200 200 3;;

I'm confused between : load graphics.cma open Graphics Graphics.open_graph 我之间感到困惑:加载graphics.cma打开Graphics Graphics.open_graph

And should I use ocamlc -og graphics.cma g.ml to compile? 并且我应该使用ocamlc -og graphics.cma g.ml进行编译吗?

i'm confued between : load graphics.cma open Graphics Graphics.open_graph 我之间的困惑:加载graphics.cma打开Graphics Graphics.open_graph

  • load is a directive of the interactive toplevel. load是交互式顶级的指令。 It is not part of the OCaml language. 它不是OCaml语言的一部分。 You are using directives to command the interactive toplevel. 您正在使用指令来命令交互式顶层。 And it is used to load code to the toplevel. 它用于将代码加载到顶层。

  • open Graphics is a language construct that will bring names of definitions in module Graph to the current scope. open Graphics是一种语言构造,它将把Graph模块中的定义名称带到当前作用域。 This allows you to write open_graph instead of Graphics.open_graph . 这使您可以编写open_graph而不是Graphics.open_graph It is better not to open too many modules (if any) as it may pollute your namespace, and make your code less understandable. 最好不要打开太多的模块(如果有的话),因为这可能会污染您的命名空间,并使您的代码难以理解。

  • Graphics.open_graph is a function, that, when invoked, will open a graphics window in your machine. Graphics.open_graph是一个函数,当调用该函数时,它将在您的计算机中打开一个图形窗口。

and should i use ocamlc -og graphics.cma g.ml to compile. 并且我应该使用ocamlc -og graphics.cma g.ml进行编译。

Yep, you can use ocamlc to compile your code. 是的,您可以使用ocamlc来编译代码。 The OCaml compiler toolchain is rather difficult to use. OCaml编译器工具链很难使用。 However, there is a compilation manager, called ocamlbuild, that should work like magic, eg, 但是,有一个名为ocamlbuild的编译管理器,应该像魔术一样工作,例如,

 ocamlbuild -pkg graphics g.byte

You will get a g.byte executable that you can run. 您将获得一个可以运行的g.byte可执行文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM