我将ocaml升级到4.03.0。 然后,一些包装器库无法构建提出“没有提供实现”错误。
我准备了一个小例子来解释我的情况。
我在hello_stubs.c
#include<stdio.h>
#include<caml/mlvalues.h>
CAMLprim value caml_print_hello(value unit)
{
printf("Hello\n");
return Val_unit;
}
接下来,我在hello.mli
。
external print_hello : unit -> unit = "caml_print_hello"
然后,我在main.ml
Hello.print_hello();;
为了编译这些程序,我执行了以下命令。
ocamlc -c hello.mli
ocamlc -c hello_stubs.c
ocamlopt -o main main.ml hello_stubs.o
然后,遗憾的是,最后一个命令失败并显示以下错误消息。
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Hello, and its interface was not compiled with -opaque
File "main.ml", line 1:
Error: No implementations provided for the following modules:
Hello referenced from main.cmx
根据消息,
我试过了ocamlc -opaque hello.mli
,但它没有解决问题。
我还确认上面的命令适用于ocaml 4.02.3。
您知道如何使用ocaml 4.03.0编译此示例吗?
答案 0 :(得分:2)
修复很简单:创建hello.ml
相同内容的hello.mli
并编译并链接main
。
我想这是由于4.03.0的以下变化:
应更新参考手册的相关部分。见http://caml.inria.fr/mantis/view.php?id=7371