【问题标题】:How to compile ocaml program with using Graphics module by ocamlopt?如何使用 ocamlopt 的 Graphics 模块编译 ocaml 程序?
【发布时间】:2016-06-17 17:39:53
【问题描述】:

据我了解,graphics.cmax 不存在。 但是如何使用 ocamlopt 的 Graphics 模块编译 ocaml 程序呢? 是否可以?也许一些替代图形库?

【问题讨论】:

    标签: graphics compilation ocaml libraries native-code


    【解决方案1】:

    好吧,graphics.cmax 确实不存在,为什么会存在呢?但是 graphics.cmxa 可以。因此,当然可以将使用图形库的程序编译为机器代码。您可以使用ocamlfind 根据您的编译模式找到合适的库。例如在我的机器上:

    $ ocamlfind query -predicates native -a-format graphics
      /home/ivg/.opam/fresh/lib/ocaml/graphics.cmxa
    

    在一个简单的情况下,像这样,使用随 OCaml 系统本身分发的图形库,您只需将 graphics.cmxa 添加到编译字符串。在更复杂的情况下,只需使用ocamlfind ocamlopt 而不是ocamlopt,并指定-package 选项来引用库名称,在您的情况下,它将是:

     $ ocamlfind ocamlopt -package graphics ...
    

    或者你可以使用ocamlbuld:

     $ ocamlbuild -package graphics my_cool_application.native
    

    您的酷应用程序在my_cool_application.ml 文件中有一个入口点。

    【讨论】:

    • 很抱歉这个粗体的愚蠢问题。连续工作两天。
    猜你喜欢
    • 1970-01-01
    • 2020-07-24
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    相关资源
    最近更新 更多