在OCaml 4.03.0中,FFI未能使用;“未提供任何实施方案”;错误

在OCaml 4.03.0中,FFI未能使用;“未提供任何实施方案”;错误,ocaml,ffi,Ocaml,Ffi,我将ocaml升级到4.03.0。 然后,一些包装器库未能构建,并引发“未提供任何实现”错误 我准备了一个小例子来解释我的情况 我在hello\u stubs.C #include<stdio.h> #include<caml/mlvalues.h> CAMLprim value caml_print_hello(value unit) { printf("Hello\n"); return Val_unit; } 然后,我在main.ml Hello.

我将ocaml升级到4.03.0。 然后,一些包装器库未能构建,并引发“未提供任何实现”错误

我准备了一个小例子来解释我的情况

我在
hello\u stubs.C

#include<stdio.h>
#include<caml/mlvalues.h>
CAMLprim value caml_print_hello(value unit)
{
    printf("Hello\n");
    return Val_unit;
}
然后,我在
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
,但没有解决问题

我还确认了上述命令在OCAML4.02.3中运行良好


您知道如何使用ocaml 4.03.0编译此示例吗?

修复方法很简单:创建
hello.ml
的内容与
hello.mli
相同,然后编译它并链接到
main

我猜这是由于4.03.0的以下更改:

  • PR#4166,PR#6956:调用外部C原语时强制链接 (雅克·加里格,马库斯·莫特尔和克里斯托夫·特罗斯特勒的报道)

应更新参考手册的相关章节。请参见

修复很简单:创建与
hello.mli
相同内容的
hello.ml
,并编译它并链接到
main

我猜这是由于4.03.0的以下更改:

  • PR#4166,PR#6956:调用外部C原语时强制链接 (雅克·加里格,马库斯·莫特尔和克里斯托夫·特罗斯特勒的报道)
应更新参考手册的相关章节。看

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