简体   繁体   English

如何编译使用JsooTop模块的文件?

[英]How to compile a file that uses the JsooTop module?

I have this in a file named main.ml : 我在名为main.ml的文件中有此文件:

let () = JsooTop.initialize ()

I tried compiling the file using: 我尝试使用以下命令编译文件:

ocamlfind ocamlc -package js_of_ocaml -linkpkg -o main.byte main.ml

But this error appears: 但是出现此错误:

File "main.ml", line 1, characters 9-27:
Error: Unbound module JsooTop

It appears that JsooTop is not present on my machine, so I ran opam install js_of_ocaml-toplevel , and tried compiling the file again using: 看来我的机器上不存在JsooTop ,所以我运行opam install js_of_ocaml-toplevel ,并尝试使用以下命令再次编译文件:

ocamlfind ocamlc -package js_of_ocaml -package js_of_ocaml-toplevel -linkpkg -o main.byte main.ml
js_of_ocaml main.byte

But I get warnings: 但是我得到警告:

Warnings from ocamlfind : 来自ocamlfind警告:

findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml, /usr/lib/ocaml/compiler-libs

Warnings from the js_of_ocaml executable: 来自js_of_ocaml可执行文件的警告:

There are some missing primitives
Dummy implementations (raising 'Failure' exception) will be used if they are not available at runtime.
You can prevent the generation of dummy implementations with the commandline option '--disable genprim'
Missing primitives provided by +dynlink.js:
  caml_add_debug_info
  caml_dynlink_add_primitive
  caml_dynlink_get_current_libs
  caml_dynlink_lookup_symbol
  caml_dynlink_open_lib
  caml_remove_debug_info
Missing primitives provided by +toplevel.js:
  caml_get_current_environment
  caml_get_section_table
  caml_invoke_traced_function
  caml_realloc_global
  caml_reify_bytecode
  caml_static_alloc
  caml_static_free
  caml_static_release_bytecode
  caml_terminfo_setup

My question is: what is the proper way to compile a file that uses the JsooTop module? 我的问题是:编译使用JsooTop模块的文件的正确方法是什么?

First, make sure that the required OPAM packages are present: 首先,确保存在所需的OPAM软件包:

opam install js_of_ocaml js_of_ocaml-toplevel

To build a program that uses the JsooTop module, compile the file in this way: 要构建使用JsooTop模块的程序,请按照以下方式编译文件:

ocamlfind ocamlc -package js_of_ocaml -package js_of_ocaml-toplevel -linkpkg -o main.byte main.ml
js_of_ocaml --toplevel --dynlink +dynlink.js +toplevel.js main.byte

Note the inclusion of --toplevel , --dynlink , +dynlink.js , and +toplevel.js . 请注意包含--toplevel ,-- --dynlink+dynlink.js+toplevel.js The commands above will produce a JavaScript file named main.js . 上面的命令将生成一个名为main.js的JavaScript文件。

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

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