我把我的ocaml升级到了4.03.0。然后,一些包装库无法构建,并引发了"No implemntations“错误。
我准备了一个小例子来解释我的情况。
我用hello_stubs.c写了一个C代码
#include<stdio.h>
#include<caml/mlvalues.h>
CAMLprim value caml_print_hello(value unit)
{
printf("Hello\n");
return Val_unit;
}接下来,在hello.mli中为ocaml准备接口文件。
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编译这个例子吗?
发布于 2016-09-26 19:03:45
修复方法很简单:创建与hello.mli内容相同的hello.ml,然后编译它并链接到main。
请参阅http://caml.inria.fr/mantis/view.php?id=7371
https://stackoverflow.com/questions/39698523
复制相似问题