0
我升級我的ocaml到4.03.0。 然後,一些包裝庫無法生成「沒有提供實現」錯誤。在OCaml 4.03.0 FFI無法編譯與「沒有實現提供」錯誤
我準備一個小例子來解釋我的情況。
我寫在hello_stubs.c
#include<stdio.h>
#include<caml/mlvalues.h>
CAMLprim value caml_print_hello(value unit)
{
printf("Hello\n");
return Val_unit;
}
接着一個C代碼,我製備接口文件爲ocaml的,在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編譯這個例子嗎?